我希望通过链接打开我的应用程序, 按照 Make a link in the Android browser start up my app? 的指示进行操作. 好吧,它工作正常(大部分时间......这就是我寻求帮助的原因)。
我的html链接是
<a href="intent:#Intent;action=com.mark.MY_ACTION;end">Open Application</a>
我的 Intent 过滤器的形式是
<intent-filter>
<action android:name="com.mark.MY_ACTION"/>
<category android:name="android.intent.category.DEFAULT">
<category android:name="android.intent.category.BROWSABLE">
</intent-filter>
到目前为止一切顺利(我希望如此)。它在 m-o-s-t 浏览器中运行良好。
为了测试上面我写了一个演示 Activity
final WebView webview = new WebView(this);
setContentView(webview);
webview.loadUrl("http://www.myhomepage.com/");
http://www.myhomepage.com/
页面有一些自定义链接/href(包括
Intent 之一)。
按常规链接会打开带有这些链接的浏览器,但按我的“特殊链接” 链接”(内部网)打开一个 404 页面
Web page not available
intent:#Intent;action=com.mark.MY_ACTION;end
might be temporarily down....
虽然黛安在 The above link 中提到,
They allow you to direct the launch to only your app without the user having the option of instead going to the browser or any other app.
最佳答案
您的 Intent Filter 与 Diana 提到的有些相同
<activity android:name=".AntonWorld"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="anton" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
所以你的应该是这样的:
<intent-filter>
<data android:scheme="com.mark.MY_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
没有测试是否需要 android.intent.category.VIEW。让我知道它是否有效。
关于java - 处理 Android 浏览器/webview 中的链接以直接启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7570253/