`
webcode
  • 浏览: 5948825 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

Android Intent调用大全

 
阅读更多
  1. //调用浏览器
  2. Uri uri = Uri.parse("");
  3. Intent it = new Intent(Intent.ACTION_VIEW,uri);
  4. startActivity(it);
  5. //显示某个坐标在地图上
  6. Uri uri = Uri.parse("geo:38.899533,-77.036476");
  7. Intent it = new Intent(Intent.Action_VIEW,uri);
  8. startActivity(it);
  9. //显示路径
  10. Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
  11. Intent it = new Intent(Intent.ACTION_VIEW,URI);
  12. startActivity(it);
  13. //拨打电话
  14. Uri uri = Uri.parse("tel:10086");
  15. Intent it = new Intent(Intent.ACTION_DIAL, uri);
  16. startActivity(it);
  17. Uri uri = Uri.parse("tel.10086");
  18. Intent it =new Intent(Intent.ACTION_CALL,uri);
  19. //需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml
  20. //发送短信或彩信
  21. Intent it = new Intent(Intent.ACTION_VIEW);
  22. it.putExtra("sms_body", "The SMS text");
  23. it.setType("vnd.android-dir/mms-sms");
  24. startActivity(it);
  25. //发送短信
  26. Uri uri = Uri.parse("smsto:10086");
  27. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  28. it.putExtra("sms_body", "cwj");
  29. startActivity(it);
  30. //发送彩信
  31. Uri uri = Uri.parse("content://media/external/images/media/23");
  32. Intent it = new Intent(Intent.ACTION_SEND);
  33. it.putExtra("sms_body", "some text");
  34. it.putExtra(Intent.EXTRA_STREAM, uri);
  35. it.setType("image/png");
  36. startActivity(it);
  37. //发送邮件
  38. Uri uri = Uri.parse("mailto:android123@163.com");
  39. Intent it = new Intent(Intent.ACTION_SENDTO, uri);
  40. startActivity(it);
  41. Intent it = new Intent(Intent.ACTION_SEND);
  42. it.putExtra(Intent.EXTRA_EMAIL, android123@163.com);
  43. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  44. it.setType("text/plain");
  45. startActivity(Intent.createChooser(it, "Choose Email Client"));
  46. Intent it=new Intent(Intent.ACTION_SEND);
  47. String[] tos={"me@abc.com"};
  48. String[] ccs={"you@abc.com"};
  49. it.putExtra(Intent.EXTRA_EMAIL, tos);
  50. it.putExtra(Intent.EXTRA_CC, ccs);
  51. it.putExtra(Intent.EXTRA_TEXT, "The email body text");
  52. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  53. it.setType("message/rfc822");
  54. startActivity(Intent.createChooser(it, "Choose Email Client"));
  55. //播放媒体文件
  56. Intent it = new Intent(Intent.ACTION_VIEW);
  57. Uri uri = Uri.parse("file:///sdcard/cwj.mp3");
  58. it.setDataAndType(uri, "audio/mp3");
  59. startActivity(it);
  60. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
  61. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  62. startActivity(it);
  63. //卸载APK
  64. Uri uri = Uri.fromParts("package", strPackageName, null);
  65. Intent it = new Intent(Intent.ACTION_DELETE, uri);
  66. startActivity(it);
  67. //卸载apk 2
  68. Uri uninstallUri = Uri.fromParts("package", "xxx", null);
  69. returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
  70. //安装APK
  71. Uri installUri = Uri.fromParts("package", "xxx", null);
  72. returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
  73. //播放音乐
  74. Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3");
  75. returnIt = new Intent(Intent.ACTION_VIEW, playUri);
  76. //发送附近
  77. Intent it = new Intent(Intent.ACTION_SEND);
  78. it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
  79. it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/cwj.mp3");
  80. sendIntent.setType("audio/mp3");
  81. startActivity(Intent.createChooser(it, "Choose Email Client"));
  82. //market上某个应用信,pkg_name就是应用的packageName
  83. Uri uri = Uri.parse("market://search?q=pname:pkg_name");
  84. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  85. startActivity(it);
  86. //market上某个应用信息,app_id可以通过www网站看下
  87. Uri uri = Uri.parse("market://details?id=app_id");
  88. Intent it = new Intent(Intent.ACTION_VIEW, uri);
  89. startActivity(it);
  90. //调用搜索
  91. Intent intent = new Intent();
  92. intent.setAction(Intent.ACTION_WEB_SEARCH);
  93. intent.putExtra(SearchManager.QUERY,"android123")
  94. startActivity(intent);
  95. //调用分享菜单
  96. Intent intent=new Intent(Intent.ACTION_SEND);
  97. intent.setType("text/plain"); //分享的数据类型
  98. intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); //主题
  99. intent.putExtra(Intent.EXTRA_TEXT, "content"); //内容
  100. startActivity(Intent.createChooser(intent, "title")); //目标应用选择对话框的标题
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics