• 总结android中Intent的用法


    总结android中Intent的用法:

    1. //显示网页
    2. Uri uri = Uri.parse("http://google.com");
    3. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    4. startActivity(it);
    5.
    6. //显示地图
    7. Uri uri = Uri.parse("geo:38.899533,-77.036476");
    8. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    9. startActivity(it);
    16.
    17. //路径规划
    18.
    19. Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat20endLng&hl=en");
    20. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    21. startActivity(it);
    22. //where startLat, startLng, endLat, endLng are a long with 6 decimals like: 50.123456
    23.
    24. //打电话
    25. //叫出拨号程序
    26. Uri uri = Uri.parse("tel:0800000123");
    27. Intent it = new Intent(Intent.ACTION_DIAL, uri);
    28. startActivity(it);
    29.
    30. //直接打电话出去
    31. Uri uri = Uri.parse("tel:0800000123");
    32. Intent it = new Intent(Intent.ACTION_CALL, uri);
    33. startActivity(it);
    34. //用這個,要在 AndroidManifest.xml 中,加上
    35. //<uses-permission id="android.permission.CALL_PHONE" />
    36.
    37. //传送SMS/MMS
    38. //调用短信程序
    39. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    40. it.putExtra("sms_body", "The SMS text");
    41. it.setType("vnd.android-dir/mms-sms");
    42. startActivity(it);
    43.
    44. //传送消息
    45. Uri uri = Uri.parse("smsto://0800000123");
    46. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
    47. it.putExtra("sms_body", "The SMS text");
    48. startActivity(it);
    49.
    50. //传送 MMS
    51. Uri uri = Uri.parse("content://media/external/images/media/23");
    52. Intent it = new Intent(Intent.ACTION_SEND);
    53. it.putExtra("sms_body", "some text");
    54. it.putExtra(Intent.EXTRA_STREAM, uri);
    55. it.setType("image/png");
    56. startActivity(it);
    57.
    58. //传送 Email
    59. Uri uri = Uri.parse("mailto:xxx@abc.com");
    60. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
    61. startActivity(it);
    62.
    63. Intent it = new Intent(Intent.ACTION_SEND);
    64. it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");
    65. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
    66. it.setType("text/plain");
    67. startActivity(Intent.createChooser(it, "Choose Email Client"));
    68.
    69. Intent it=new Intent(Intent.ACTION_SEND);
    70. String[] tos={"me@abc.com"};
    71. String[] ccs={"you@abc.com"};
    72. it.putExtra(Intent.EXTRA_EMAIL, tos);
    73. it.putExtra(Intent.EXTRA_CC, ccs);
    74. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
    75. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
    76. it.setType("message/rfc822");
    77. startActivity(Intent.createChooser(it, "Choose Email Client"));
    78.
    79. //传送附件
    80. Intent it = new Intent(Intent.ACTION_SEND);
    81. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
    82. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
    83. sendIntent.setType("audio/mp3");
    84. startActivity(Intent.createChooser(it, "Choose Email Client"));
    85.
    86. //播放多媒体
    87. Uri uri = Uri.parse("file:///sdcard/song.mp3");
    88. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    89. it.setType("audio/mp3");
    90. startActivity(it);
    91.
    92. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
    93. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    94. startActivity(it);
    95.
    96. //Market 相关
    97. //寻找某个应用
    98. Uri uri = Uri.parse("market://search?q=pname:pkg_name");
    99. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    100. startActivity(it);
    101. //where pkg_name is the full package path for an application
    102. //显示某个应用的相关信息
    103. Uri uri = Uri.parse("market://details?id=app_id");
    104. Intent it = new Intent(Intent.ACTION_VIEW, uri);
    105. startActivity(it);
    106. //where app_id is the application ID, find the ID
    107. //by clicking on your application on Market home
    108. //page, and notice the ID from the address bar
    109.
    110. //Uninstall 应用程序
    111. Uri uri = Uri.fromParts("package", strPackageName, null);
    112. Intent it = new Intent(Intent.ACTION_DELETE, uri);
    113. startActivity(it);

  • 相关阅读:
    WCF系列(五) 也谈序列化(下)
    优秀程序员的十个习惯
    WCF系列(九) WCF安全系列(四) WSHttpBinding绑定之Transport安全模式
    TCP/IP 协议简单分析
    技巧:在Silverlight应用程序中进行数据验证
    WCF系列(三) WCF配置文件注释
    [转]ASP.NET(C#)常用代码30例
    服务器端 在iframe中控制父窗体div并调用父窗体Button
    GridView的模版列中加入按钮,触发按钮事件后,如何获取该行的某个值?
    通用分页 模块
  • 原文地址:https://www.cnblogs.com/tanlon/p/1958694.html
Copyright © 2020-2023  润新知