当用户点击给定模式的URL而不是允许浏览器打开它时,我希望能够启动已安装的应用程序。这可能是用户在浏览器中的网页上。
例如,点击手机中任意位置的YouTube链接,您就有机会打开之前安装的YouTube应用
如何为自己的应用实现这一目标?
答案 0 :(得分:2)
在MyLinkActivity中:
String url = getIntent().getDataString();
在你的清单中:
<activity
android:name=".MyLinkActivity">
<intent-filter>
<data
android:host="*.myurl.com"
android:scheme="http" />
<data
android:host="myurl.com"
android:scheme="http" />
<data
android:host="*.myurl.com"
android:scheme="https" />
<data
android:host="myurl.com"
android:scheme="https" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>