废话不多少,直接上代码
<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="ebjrd.weshare.com.cn"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
/**
* dataString :唤起app的链接
*/
Intent intent = getIntent();
String dataString = intent.getDataString();
通过上述方式,用户点击链接,手机会默认弹出选项框,这个选项框里包括你手机上能够打开这条链接的所有app(大多数为浏览器),其中包括你自己打应用;要想只唤起自己app,可以将链接http或https协议换成自定义协议,但是自定义协议的链接再短信和微信中不会被识别为链接,我们可以在短信或者微信中放http或者https协议的链接,让后对链接做重定向。这样的的话点击链接就会只唤起自己的app。