【发布时间】:2013-05-13 11:24:22
【问题描述】:
当用户单击给定模式的 URL 而不是允许浏览器打开它时,我希望能够启动已安装的应用程序。这可能是当用户在浏览器中的网页上时。
例如,从手机中的任意位置点击 YouTube 链接,您就有机会打开之前安装的 YouTube 应用
如何为我自己的应用实现这一点?
【问题讨论】:
标签: android android-layout android-intent android-emulator android-webview
当用户单击给定模式的 URL 而不是允许浏览器打开它时,我希望能够启动已安装的应用程序。这可能是当用户在浏览器中的网页上时。
例如,从手机中的任意位置点击 YouTube 链接,您就有机会打开之前安装的 YouTube 应用
如何为我自己的应用实现这一点?
【问题讨论】:
标签: android android-layout android-intent android-emulator android-webview
在您的 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>
【讨论】: