{"id":74,"date":"2015-07-31T08:58:59","date_gmt":"2015-07-31T08:58:59","guid":{"rendered":"https:\/\/boochlin.com\/?p=74"},"modified":"2016-07-13T14:34:54","modified_gmt":"2016-07-13T14:34:54","slug":"android-intents-with-chrome","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=74","title":{"rendered":"Android Intents with Chrome"},"content":{"rendered":"<p>\u8b93\u7db2\u9801\u53bb\u9023\u7d50 android ap<br \/>\n\u9019\u662f\u9084\u883b\u6b63\u5e38\u7684\u9700\u6c42\u884d\u751f\uff0c\u4e3b\u8981\u53ef\u4ee5\u4f86\u770b google play store \uff0c\u7576\u4f60\u5728\u901b\u4e00\u4e9bapp \u4ecb\u7d39\u6642<br \/>\n\u770b\u5230link\u76f4\u63a5\u9ede\u4e0b\u53bb\uff0c\u901a\u5e38\u6709\u5169\u7a2e\u53ef\u80fd<br \/>\n1. \u76f4\u63a5\u958b\u555f\u65b0\u5206\u9801\u5230 play store \u4e0b\u8f09\u9801\u9762<br \/>\n2. \u555f\u52d5play store app \uff0c\u7136\u5f8c\u9032\u5165\u4e0b\u8f09\u9801\u9762<\/p>\n<p>\u9019\u6b21\u8981\u8ac7\u7684\u5c31\u662f\u7b2c\u4e8c\u9ede<\/p>\n<h3><strong>\u5982\u4f55\u8b93\u7db2\u9801\u7684\u9023\u7d50\u5177\u6709\u958b\u555fapp\u7684\u6548\u529b<\/strong><\/h3>\n<p><!--more--><\/p>\n<p><a href=\"https:\/\/developer.chrome.com\/multidevice\/android\/intents\" target=\"_blank\">\u82f1\u6587\u5b98\u7db2<\/a><\/p>\n<p><a href=\"https:\/\/developers.google.com\/app-indexing\/webmasters\/app?hl=zh-tw\" target=\"_blank\">\u4e2d\u6587\u5b98\u7db2<\/a><br \/>\n\u4e2d\u6587\u5c45\u7136\u5beb\u7684\u6bd4\u8f03\u8a73\u7d30<\/p>\n<p>\u61f6\u7684\u770b\u5b98\u7db2\u7684\u8a71<br \/>\n\u4ee5\u4e0b\u7bc0\u9304\u91cd\u9ede\uff0c\u4ee5\u53ca\u5f8c\u9762\u6e2c\u8a66\u5fc3\u5f97<\/p>\n<p>intent:<br \/>\nHOST\/URI-path \/\/ Optional host<br \/>\n#Intent;<br \/>\npackage=[string];<br \/>\naction=[string];<br \/>\ncategory=[string];<br \/>\ncomponent=[string];<br \/>\nscheme=[string];<br \/>\nend;<\/p>\n<p>\u5c0d\u61c9\u5230<br \/>\nintent:<br \/>\n\/\/scan\/<br \/>\n#Intent;<br \/>\npackage=com.google.zxing.client.android;<br \/>\nscheme=zxing;<br \/>\nend;<br \/>\n\u5beb\u51fa\u4f86\u61c9\u8a72\u6703\u50cf\u662f<br \/>\n&lt;a href=&#8221;intent:\/\/scan\/#Intent;scheme=zxing;package=com.google.zxing.client.android;end&#8221;&gt; Take a QR code &lt;\/a&gt;<br \/>\n\u4e0a\u8ff0\u662fgoogle \u7684\u6559\u5b78\u8cc7\u6599 \u6839\u64da\u81ea\u5df1\u6e2c\u8a66\u7d50\u679c<br \/>\n&lt;a href=&#8221;intent:\/\/com.android.launcher3\/#Intent;scheme=http;action=com.android.ACTION.LAUNCH_LEFTPAGE;end;&#8221;&gt;<br \/>\nstart launcher&lt;\/a&gt;<br \/>\n\u5982\u679c\u5c0d\u61c9\u5230\u81ea\u5df1\u76f8\u95dc\u7684ap \uff0c\u5fc5\u9808\u5148\u5728 android manifest \u88e1\u52a0\u5165 intent filter<\/p>\n<p>&lt;intent-filter&gt;<br \/>\n&lt;action android:name=&#8221;android.intent.action.VIEW&#8221; \/&gt;<br \/>\n&lt;action android:name=&#8221;com.android.ACTION.LAUNCH_LEFTPAGE&#8221; \/&gt;<br \/>\n&lt;data android:scheme=&#8221;http&#8221;<br \/>\nandroid:host=&#8221;com.android.launcher3&#8243;\/&gt;<br \/>\n&lt;category android:name=&#8221;android.intent.category.DEFAULT&#8221; \/&gt;<br \/>\n&lt;category android:name=&#8221;android.intent.category.BROWSABLE&#8221; \/&gt;<br \/>\n&lt;\/intent-filter&gt;<br \/>\n\u4ee5\u4e0a\u662f\u6700\u57fa\u672c\u7684\u914d\u7f6e\u8cc7\u6599 \u5982\u679c\u4f60\u6210\u529f\u52a0\u5165\u5230\u4f60\u7684app \u4e4b\u5f8c\uff0c\u53ef\u4ee5\u5148\u7528 adb \u4f86\u9032\u884c\u6e2c\u8a66<\/p>\n<pre>adb shell am start -a com.android.ACTION.LAUNCH_APP -d \"http:\/\/com.android.launcher3\"\r\n<\/pre>\n<p>\u9019\u6a23\u61c9\u8a72\u6703\u6210\u529f\u958b\u555f\u4f60\u7684app<br \/>\n\u63a5\u8005\u9032\u5165\u6b63\u984c<\/p>\n<p><a href=\"intent:\/\/com.android.launcher3\/#Intent;action=com.android.ACTION.LAUNCH_APP;scheme=http;end\"> start your app<\/a><br \/>\n\u9ede\u64ca\u4e0a\u8ff0\u9023\u7d50\uff0c\u61c9\u8a72\u5c31\u6703\u958b\u555f\u4f60\u7684activity.<\/p>\n<p>\u5176\u4ed6\u88dc\u5145\u4e8b\u9805\uff1a<br \/>\n1.&lt;<span class=\"tag\">action<\/span> <span class=\"atn\">android:name<\/span><span class=\"pun\">=<\/span><span class=\"atv\">&#8220;android.intent.action.VIEW&#8221;<\/span> <span class=\"tag\">\/&gt;<\/span><br \/>\n\u53ef\u52a0\u53ef\u4e0d\u52a0\uff0c\u9019\u53ea\u662f\u591a\u5c0d\u61c9\u4e00\u7a2e view action.(\u901a\u5e38browser\u6703\u767c)<br \/>\n2.<span class=\"tag\">&lt;category<\/span> <span class=\"atn\">android:name<\/span><span class=\"pun\">=<\/span><span class=\"atv\">&#8220;android.intent.category.BROWSABLE&#8221;<\/span> <span class=\"tag\">\/&gt;<\/span><br \/>\n\u9019\u500b\u4e00\u5b9a\u8981\u52a0\uff0c\u57fa\u672c\u4e0a\u9019\u5c31\u662f\u898f\u5247<br \/>\nOnly activities that have the category filter, android.intent.category.BROWSABLE are able to be invoked using this method as it indicates that the application is safe to open from the Browser.<br \/>\n3.<span class=\"tag\">&lt;category<\/span> <span class=\"atn\">android:name<\/span><span class=\"pun\">=<\/span><span class=\"atv\">&#8220;android.intent.category.DEFAULT&#8221;<\/span> <span class=\"tag\">\/&gt;<\/span><br \/>\n\u9019\u500b\u57fa\u672c\u4e0a\u5df2\u7d93\u662f\u5c0dandroid \u4e86\u4e0d\u4e86\u89e3\u7684\u554f\u984c\uff0c\u4e0d\u52a0\u7684\u8a71 app \u7121\u6cd5\u958b\u555f\u9019\u500bactivity.<br \/>\n4. host \u662f\u4e0d\u4e00\u5b9a\u8981\u52a0\uff0c\u4f46\u662f\u6c92\u6709host \u5c31\u4e00\u5b9a\u8981\u52a0 path (\u53ef\u4ee5\u53c3\u8003<a href=\"https:\/\/developer.chrome.com\/multidevice\/android\/intents\" target=\"_blank\">\u5b98\u7db2<\/a>\u7684\u5169\u7a2e\u5beb\u6cd5)<br \/>\n\u4e5f\u53ef\u4ee5\u53ea\u6709host<\/p>\n<p>\u5176\u4ed6\u795e\u5947\u60c5\u6cc1\uff1a<br \/>\n1.\u4f60\u8aaa\u4f60\u9ede\u4e86\u4e0a\u9762\u7684\u9023\u7d50 app \u537b\u6c92\u6709\u53cd\u61c9<br \/>\n\u5ee2\u8a71\uff0c\u4f60\u5728\u96fb\u8166\u4e0a\u9762\u7528\u6ed1\u9f20\u9ede\u64ca\u7576\u7136\u6c92\u5c41\u7528\u963f<br \/>\n2.\u4f60\u8aaa\u4f60\u5728\u624b\u6a5f\u4e0a\u9762\u958b\u5b98\u65b9browser\u9ede\u64ca\u4e86\u963f\uff0capp \u9084\u662f\u6c92\u53cd\u61c9<br \/>\n\u4f60\u7684browser\u53ef\u80fd\u6c92porting \u9019\u6bb5<a href=\"https:\/\/code.google.com\/p\/android-source-browsing\/source\/browse\/core\/java\/android\/content\/Intent.java?repo=platform--frameworks--base#6514\">code<\/a><br \/>\n3.\u4f60\u8aaa\u4f60\u958b chrome \u624d\u53bb\u9ede\u64ca\u7684<br \/>\n\u5509\uff0c\u9019\u529f\u80fd\u4e5f\u662fgoogle \u5f8c\u4f86\u624d\u60f3\u5230\u7684\uff0c\u53bb\u66f4\u65b0\u4e00\u4e0b\u4f60\u7684chrome<br \/>\n4.\u4f60\u8aaa\u5176\u4ed6browser\uff08firefox,\u767e\u5ea6\uff09\u9ede\u64ca\u4e86\u6c92\u7528<br \/>\n\u7cdf\u7cd5\uff0c\u5176\u4ed6browser\u7576\u7136\u6c92\u6709parsing\u9019\u6bb5\u7db2\u9801\u7684\u529f\u80fd\uff0c\u9019\u529f\u80fd\u57fa\u672c\u4e0a\u53ea\u6709 chrome , \u539f\u751fbrowser \u6703 support.<br \/>\n5.\u4ee5\u4e0a\u6211\u90fd\u6709\u641e\u5b9a\uff0c\u4f46\u9084\u662f\u4e0d\u80fd\u7528<br \/>\n\u90a3\u61c9\u8a72\u662f\u6211\u7684\u554f\u984c\uff0c\u62b1\u6b49\uff0c\u4f60\u53ef\u4ee5\u7559\u8a00\u53cd\u61c9\uff0c\u8b1d\u8b1d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8b93\u7db2\u9801\u53bb\u9023\u7d50 android ap \u9019\u662f\u9084\u883b\u6b63\u5e38\u7684\u9700\u6c42\u884d\u751f\uff0c\u4e3b\u8981\u53ef\u4ee5\u4f86\u770b google play store \uff0c\u7576\u4f60\u5728\u901b\u4e00\u4e9bapp \u4ecb\u7d39\u6642 \u770b\u5230link\u76f4\u63a5\u9ede\u4e0b\u53bb\uff0c\u901a\u5e38\u6709\u5169\u7a2e\u53ef\u80fd 1. \u76f4\u63a5\u958b\u555f\u65b0\u5206\u9801&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50],"tags":[18,9,19],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/74"}],"collection":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":0,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}