{"id":1349,"date":"2012-03-13T16:41:29","date_gmt":"2012-03-13T08:41:29","guid":{"rendered":"http:\/\/leybreeze.com\/blog\/?p=1349"},"modified":"2012-03-13T16:42:08","modified_gmt":"2012-03-13T08:42:08","slug":"android%e4%b8%ad%e9%80%9a%e8%bf%87intent%e8%b0%83%e7%94%a8%e5%85%b6%e4%bb%96%e5%ba%94%e7%94%a8%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/leybreeze.com\/blog\/?p=1349","title":{"rendered":"Android\u4e2d\u901a\u8fc7Intent\u8c03\u7528\u5176\u4ed6\u5e94\u7528\u7684\u65b9\u6cd5"},"content":{"rendered":"<p><strong>\u542f\u52a8\u6d4f\u89c8\u5668<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(\"http:\/\/www.google.com\"));  \r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u6d4f\u89c8\u5668\u5e76\u524d\u5f80http:\/\/www.google.com \u3002<\/p>\n<p><strong>\u542f\u52a8\u62e8\u53f7\u7a0b\u5e8f<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(\"tel:138\"));\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u62e8\u53f7\u7a0b\u5e8f\u5e76\u8f93\u5165\u53f7\u7801138\u3002<\/p>\n<p><strong>\u901a\u8bdd<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri uri=Uri.parse(\"tel:138\");\r\nIntent intent=new Intent(Intent.ACTION_CALL,uri);\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u62e8\u6253\u53f7\u7801138\u3002\u9700\u8981\u4e3a\u7a0b\u5e8f\u7533\u8bf7\u6743\u9650&lt;uses-permission android:name=&#8221;android.permission.CALL_PHONE&#8221;\/&gt;\u3002<\/p>\n<p><strong>\u53d1\u9001\u77ed\u4fe1<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri smsUri = Uri.parse(url);\r\nIntent intent = new Intent(Intent.ACTION_VIEW, smsUri);\r\nintent.setType(\"vnd.android-dir\/mms-sms\");\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u77ed\u4fe1\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u542f\u52a8\u901a\u8baf\u5f55<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(\"content:\/\/contacts\/people\/1\"));\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u540c\u5b66\u5f55\u7684\u67d0\u4e00\u6761\u76ee\u3002<\/p>\n<p><strong>\u542f\u52a8\u5730\u56fe\u7a0b\u5e8f\uff08Google Maps\u7b49\uff09<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri mapUri = Uri.parse(url);\r\nIntent intent = new Intent(Intent.ACTION_VIEW, mapUri);\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u5730\u56fe\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u641c\u7d22\u8def\u7ebf<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent();\r\nintent.setAction(Intent.ACTION_VIEW);\r\nintent.setClassName(\"com.google.android.apps.maps\",\"com.google.android.maps.MapsActivity\");\r\nintent.setData(Uri.parse(\"http:\/\/maps.google.com\/maps?myl=saddr&amp;daddr=&amp;dirflg=d\"));\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8Google Maps\u5e76\u641c\u7d22\u8def\u7ebf\uff0c\u5177\u4f53\u7684\u65b9\u6cd5\u53e6\u5916\u8865\u5145\u3002<\/p>\n<p><strong>\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri uri =Uri.parse(\"mailto:xxx@example.com\");\r\nIntent intent = newIntent(Intent.ACTION_SENDTO, uri);\r\nintent.putExtra(Intent.EXTRA_SUBJECT, \"Hello world\");\r\nintent.putExtra(Intent.EXTRA_TEXT, \"Ganbarimasu\");\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f\u5e76\u5c06\u6536\u4ef6\u4eba\u8bbe\u4e3axxx@example.com\uff0c\u90ae\u4ef6\u4e3b\u9898\u8bbe\u4e3aHello world\uff0c\u5185\u5bb9\u8bbe\u4e3aGanbarimasu\u3002<\/p>\n<p><strong>\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f\u5e76\u6dfb\u52a0\u591a\u4e2a\u6536\u4ef6\u4eba<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent=new Intent(Intent.ACTION_SEND);     \r\nString[] tos={\"me@example.com\"};     \r\nString[]ccs={\"you@example.com\"};     \r\nintent.putExtra(Intent.EXTRA_EMAIL, tos);     \r\nintent.putExtra(Intent.EXTRA_CC, ccs);     \r\nintent.putExtra(Intent.EXTRA_TEXT, \"The email body text\");     \r\nintent.putExtra(Intent.EXTRA_SUBJECT, \"The email subject text\");     \r\nintent.setType(\"message\/rfc822\");     \r\nstartActivity(Intent.createChooser(intent,\"Choose Email Client\"));<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f\u5e76\u8bbe\u7f6e\u4e3a\u53d1\u9001\u7ed9\u591a\u4e2a\u6536\u4ef6\u4eba\u3002<\/p>\n<p><strong>\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f\u5e76\u6dfb\u52a0\u9644\u4ef6<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = newIntent(Intent.ACTION_SEND);   \r\nintent.putExtra(Intent.EXTRA_SUBJECT, \"The email subject text\");    \r\nintent.putExtra(Intent.EXTRA_STREAM,\"file:\/\/\/sdcard\/mysong.mp3);   \r\nsendIntent.setType(\"audio\/mp3\");   \r\nstartActivity(Intent.createChooser(intent,\"Choose Email Client\"));<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u90ae\u4ef6\u7a0b\u5e8f\u5e76\u6dfb\u52a0\u9644\u4ef6\u3002<\/p>\n<p><strong>\u64ad\u653eMP3\u6587\u4ef6<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent(Intent.ACTION_VIEW);\r\nUri uri =Uri.parse(\"file:\/\/\/sdcard\/song.mp3\");\r\nintent.setDataAndType(uri,\"audio\/mp3\");\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u97f3\u4e50\u7a0b\u5e8f\u5e76\u64ad\u653eMP3\u6b4c\u66f2\u3002<\/p>\n<p><strong>\u5378\u8f7d\u7a0b\u5e8f<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri uri =Uri.fromParts(\"package\", strPackageName, null);   \r\nIntent intent = newIntent(Intent.ACTION_DELETE, uri);   \r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u5378\u8f7d\u5305\u540d\u4e3astrPackageName\u7684\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri installUri = Uri.fromParts(\"package\",strPackageName, null);\r\nreturnIt = newIntent(Intent.ACTION_PACKAGE_ADDED, installUri);<\/pre>\n<p>\u8bf4\u660e\uff1a\u5b89\u88c5\u5305\u540d\u4e3astrPackageName\u7684\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u542f\u52a8\u8bbe\u7f6e<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent=new Intent(\"android.settings.SETTINGS\");\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u8fdb\u5165\u8bbe\u5b9a\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u542f\u52a8\u7535\u5b50\u5e02\u573a<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri uri=Uri.parse(\"market:\/\/search?q=pname:org.breezesoft.techolite\");\r\nIntent intent=new Intent(Intent.ACTION_VIEW,uri);\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u4ee5\u5305\u540dorg.breezesoft.techolite\u4e3a\u6761\u4ef6\u542f\u52a8Android Market\u3002<\/p>\n<p><strong>\u542f\u52a8\u7535\u5b50\u5e02\u573a\u5e76\u8fdb\u5165\u7a0b\u5e8f\u4fe1\u606f\u754c\u9762<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Uri uri = Uri.parse(\"market:\/\/details?id=org.breezesoft.techolite\");\r\nIntent intent = new Intent(Intent.ACTION_VIEW, uri);\r\nstartActivity(intent);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8Android Market\u5e76\u8fdb\u5165\u5305\u540d\u4e3aorg.breezesoft.techolite\u7684\u7a0b\u5e8f\u7684\u8be6\u7ec6\u4fe1\u606f\u754c\u9762\u3002<\/p>\n<p><strong>\u4ece\u56fe\u5e93\uff08Gallery\uff09\u4e2d\u9009\u62e9\u5e76\u83b7\u53d6\u4e00\u5f20\u56fe\u7247<\/strong><\/p>\n<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<pre lang=\"JAVA\">Intent intent = new Intent();\r\nintent.setType(\"image\/*\");\r\nintent.setAction(Intent.ACTION_GET_CONTENT);\r\nstartActivityForResult(intent, 11);<\/pre>\n<p>\u8bf4\u660e\uff1a\u542f\u52a8\u56fe\u5e93\u5e76\u4e2d\u9009\u62e9\u5e76\u83b7\u53d6\u4e00\u5f20\u56fe\u7247\uff0c\u8fd4\u56de\u539f\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u52a8\u6d4f\u89c8\u5668 \u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a Intent intent = new Intent(Intent.ACTION_V &hellip; <a href=\"http:\/\/leybreeze.com\/blog\/?p=1349\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cAndroid\u4e2d\u901a\u8fc7Intent\u8c03\u7528\u5176\u4ed6\u5e94\u7528\u7684\u65b9\u6cd5\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[5,101,40],"_links":{"self":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1349"}],"collection":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1349"}],"version-history":[{"count":2,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1349\/revisions"}],"predecessor-version":[{"id":1351,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1349\/revisions\/1351"}],"wp:attachment":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1349"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}