rya*_*yan 3 android google-chrome
我正在开发一个Android应用程序来处理某些http(s)链接的意图.它适用于大多数情况,但不适用于Chrome中的链接点击,因为此错误/缺少功能.简而言之,Chrome不会广播这些点击的意图.:/
最终可能会修复,但与此同时,是否有人知道解决方法?
如果我自己控制链接,我可以使用我自己的HTTP方案,例如myapp:// ...,或者我可以使用JavaScript伪造按钮点击,两者都发送意图......但我无法控制链接.
具体来说,我想处理像http://github.com/snarfed这样的链接.我的活动的定义AndroidManifest.xml如下.它正确接收来自其他应用的这类链接点击的意向广播,而不是来自Chrome.
<activity android:name="MyApp" android:exported="true">
<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:scheme="http" />
<data android:scheme="https" />
<data android:host="github.com" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
您需要在每个数据点中包含scheme,host和pathPrefix.
适当清单的示例:
<activity
android:name=".PhotostreamActivity"
android:label="@string/application_name">
<!-- ... -->
<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:scheme="http"
android:host="flickr.com"
android:pathPrefix="/photos/" />
<data android:scheme="http"
android:host="www.flickr.com"
android:pathPrefix="/photos/" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
此示例取自Romain Guy放在一起的应用程序,并在此处重复提问:
需要注意的几点需要注意,似乎你需要在意图映射生效之前在后台杀死Chrome.如果你直接输入网址,应用程序就不会被允许使用它,只有当它是Chrome提供的链接时应用程序的动作.