我不希望我的应用在打开 URL 时出现在选择器对话框中 [英] I don't want my app to appear on the chooser dialog when opening URL's

查看:22
本文介绍了我不希望我的应用在打开 URL 时出现在选择器对话框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作栏上有一个操作按钮,点击时会打开一个固定的 url,它工作正常,但我不希望我自己的应用程序出现在选择器对话框使用完成操作"中,它应该只显示手机默认值浏览器(如 Chrome 或 Mozilla),实际上它显示 Chrome 和我的应用程序作为打开 url 的选项.我从这里实现了这段代码:http://developer.android.com/intl/es/guide/components/intents-common.html

I have an action button on my action bar that opens a fixed url when clicked, it works fine, but I dont want my own app to appear on the chooser dialog "complete action using", it should just appears the phone default browsers (like Chrome or Mozilla), actually It appears Chrome and my app as options to open the url. I implemented this code from here: http://developer.android.com/intl/es/guide/components/intents-common.html

这是我的代码:

//Manifest.xml

//Manifest.xml

<activity
        android:name="pepubli.com.Controlador.Ciudad_Escogida"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="http"/>
            <category android:name="android.intent.category.DEFAULT" />
            <!-- The BROWSABLE category is required to get links from web 
            pages. -->
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity> 

//Ciudad_Escogida.Java

//Ciudad_Escogida.Java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if(item.getItemId() == R.id.web_page){

        Uri webpage = Uri.parse("http://www.pepubli.com");
        Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }

    }
    return super.onOptionsItemSelected(item);
}

推荐答案

从您的应用程序清单中删除这一行.

remove this line from your application manifest.

 <category android:name="android.intent.category.BROWSABLE" />

也删除

<data android:scheme="http"/>

并替换

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

所以你的意图过滤器应该像

so your intent filter should be like

  <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter> 

这篇关于我不希望我的应用在打开 URL 时出现在选择器对话框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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