AndroidManifest.xml在Activity里加入scheme
1 2 3 4 5 6 7 8 9 |
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="cn.huangwm.test" android:pathPrefix="/open" android:scheme="huangwm" /> </intent-filter> |
例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<activity android:name=".SplashActivity" android:label="@string/title_activity_splash" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="cn.huangwm.test" android:pathPrefix="/open" android:scheme="huangwm" /> </intent-filter> </activity> |
如果是主Activity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="cn.huangwm.test" android:pathPrefix="/open" android:scheme="huangwm" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> |
在Activity.java里接收事件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent _intent = getIntent(); String action = _intent.getAction(); if(Intent.ACTION_VIEW.equals(action)){ Uri uri = _intent.getData(); if(uri != null){ String arg1 = uri.getQueryParameter("arg1"); String arg2 = uri.getQueryParameter("arg2"); } } } |
在网页里加入链接
1 |
<a href="huangwm://cn.huangwm.test/open?arg1=aaa&arg2=bbb">打开App</a> |
测试:打开App
“android 通过浏览器访问链接打开app”上的265条回复
I have been surfing on-line more than three hours these days, yet I never discovered any attention-grabbing article like yours. It’s beautiful worth sufficient for me. In my view, if all webmasters and “링크판“bloggers made good content as you did, the net can be much more useful than ever before.
This is the best weblog for anyone who desires to find out about this “야동”
topic. You notice a lot its virtually laborious to argue with you (not that I really would want aHa). You positively put a new spin on a topic thats been written about for years. Nice stuff, simply great!
Wonderful beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog web site? The account aided me a “카지노”
acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea
Great ? I should certainly pronounce, impressed with your site.
I had no trouble navigating through all tabs as well
as related information ended up being truly easy to do to access.
I recently found what I hoped for before you know it in the least.
Reasonably unusual. Is likely to appreciate it for those who add forums or something,
site theme . a tones way for your client to communicate.
Excellent task.
Its like you read my mind! You appear to know a lot about this,
like you wrote the book in it or something.
I think that you can do with a few pics to drive the message home
a bit, but other than that, this is excellent blog. An excellent read.
I’ll definitely be back.
Here is my web site: yucca Rostrata