简体   繁体   English

Intent过滤器适用于Google+,但不适用于Chrome和Facebook

[英]Intent filter works from Google+, but not Chrome & Facebook

I have the following in my AndroidManifest.xml file for my app on Google Play : 在Google Play上的应用的 AndroidManifest.xml文件中有以下内容:

    <activity
        android:name="com.enigmadream.picturecode.Viewer"
        android:exported="true"
        android:label="@string/title_activity_viewer"
        android:parentActivityName="com.enigmadream.picturecode.Editor" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.enigmadream.picturecode.Editor" />

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data
                android:host="picturecode.enigmadream.com"
                android:scheme="http" />
        </intent-filter>
    </activity>

And I thought it was working just fine. 而且我觉得它工作正常。 It still seems to work just fine if you click on a link from Google+ - it offers the option to launch my app instead of the browser when you click on a link that uses the server name picturecode.enigmadream.com . 如果您点击Google+上的链接,它似乎仍然可以正常工作 - 当您单击使用服务器名称picturecode.enigmadream.com的链接时,它提供了启动我的应用而不是浏览器的选项。 But when I click on a link to picturecode.enigmadream.com from within Facebook or Chrome, it doesn't offer the option, and instead just navigates to the page in Chrome. 但是当我从Facebook或Chrome中点击picturecode.enigmadream.com链接时 ,它不提供该选项,而只是导航到Chrome中的页面。 What am I missing? 我错过了什么?

You need to use your own scheme (eg. picturecode://). 您需要使用自己的方案(例如picturecode://)。 Facebook and Chrome can both probably deal with the http scheme on their own and so don't check to see if any other activities can handle it. Facebook和Chrome都可能自己处理http方案,因此不要检查是否有任何其他活动可以处理它。 The upshot of this is that you may not need to have the host in place either, for a shorter URI. 这样做的结果是,对于较短的URI,您可能不需要使用主机。 Just picturecode://01sv... . 只是picturecode://01sv... You can of course also keep this filter in place as well. 您当然也可以保留此过滤器。 If a browser gets to the page, just have a link that goes to the correct URI, or even just automatically redirect if possible. 如果浏览器访问该页面,只需要一个链接到正确的URI,或者甚至只是自动重定向。

For reference, you can see Google Play work this way using the market:// scheme. 作为参考,您可以使用market:// scheme以这种方式查看Google Play。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM