如何阻止URL打开我的Andr​​oid应用? [英] How to block URL to open my android app?

查看:131
本文介绍了如何阻止URL打开我的Andr​​oid应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序允许打开其他网站,如 http://www.google.com 在从应用程序的Web浏览器。而我的code如下。

My android app allows to open other website like "http://www.google.com" in a web browser from app. And my code is below.

<activity
    android:name=".HomeActivity"
    android:launchMode="singleTop"
    android:screenOrientation="portrait" >
    <intent-filter>
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.VIEW" />

        <data android:scheme="http" />
        <data android:scheme="https" />
    </intent-filter>
</activity>

但是,这给了我一个问题。在电子邮件或文本消息中,单击任何网站链接,将有来自我的应用程序打开一个选择。见我张贴的图片。如果我在短信点击www.google.com,我会选择从我的应用程序打开。

But this gives me a problem. In the email or text message, click any website link, there will be a choice to open from my app. See the picture I posted. If I click on www.google.com in the text message, I will get a choice to open from my app.

我不希望弹出窗口显示我的应用程序。如何处理呢?请帮忙。非常感谢。

I don't want the popup shows my app. How to handle this? Please help. Thanks a lot.

推荐答案

被显示在完整行动应用中使用的,因为你的意图过滤器的选择器:

Your app is being displayed in the Complete Action Using chooser because of your intent-filter:

<intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="http" />
            <data android:scheme="https" />
        </intent-filter>

和尤其是因为您指定只是一个方案项,没有特定的主人。这实际上提供任何网页的URL意图在你的应用程序中打开。

and particularly because you've specified just a "scheme" entry, with no specific "host". This would in effect offer any web URL intent to open in your app.

不理解你的意图的行为究竟是,你可以删除的&lt;&数据GT;从你的意图过滤器节点从选配您的应用。

Without understanding what your intended behavior exactly is, you can delete the <data> nodes from your intent-filter to remove your app from the Chooser.

或者,你可能想具体的URL提供您的应用程序在选配,如 http://yourserver.com https://yourserver.com ,为此,你可以改变你的意图过滤器如下:

Or alternatively, you might want specific URL's to offer your app in the Chooser, like http://yourserver.com and https://yourserver.com, for this you could alter your intent-filter as follows:

<data android:scheme="http" android:host="yourserver.com" />

这篇关于如何阻止URL打开我的Andr​​oid应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆