简体   繁体   English

我不希望我的应用在打开URL时出现在选择器对话框中

[英]I don't want my app to appear on the chooser dialog when opening URL's

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. 我在操作栏上有一个操作按钮,当单击该按钮时会打开一个固定的url,它可以正常工作,但是我不希望自己的应用程序出现在选择器对话框“使用完整操作”中,它应该只显示手机默认的浏览器(例如Chrome或Mozilla),实际上它似乎是Chrome和我的应用程序作为打开URL的选项。 I implemented this code from here: http://developer.android.com/intl/es/guide/components/intents-common.html 我从这里实现了以下代码: http : //developer.android.com/intl/es/guide/components/intents-common.html

This is my code: 这是我的代码:

//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" />

also remove 也删除

<data android:scheme="http"/>

and replace 并更换

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

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

to

<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> 

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

相关问题 JavaFx - 结束对话框不希望出现 - JavaFx - End Dialog don't want to appear 如何让我的应用程序出现在app chooser中? - How do I make my app appear in app chooser? 当我运行应用程序时,活动 xml 的更改不会出现在我的设备上 - The changes of the activity xml don't appear on my device when I run the app 当用户wifi关闭时,我不想在Android应用中显示我的webviews网址 - I don't want to show my webviews url in Android apps when users wifi is off 当应用程序在后台时,对话框不出现 - Dialog doesn't appear when the app is in the background 在其他计算机上打开时,构建后图标未出现 - Icons don't appear after build when opening on other computer 当用户想要退出我的应用程序时,为我的应用程序对话框评分 - Rate my app dialog when the user want to exit my app 在Swing中使用null布局时,直到将鼠标悬停在它们上时,我的组件才会显示 - When using null layout in Swing, my components don't appear until I hover on them 为什么我的简单Toast不想出现并且应用程序崩溃? - Why my simple Toast doesn't want to appear and the app crashes? 使用LayoutManager时,为什么这些小部件不会出现在我的Frame中? - Why don't these widgets appear in my Frame when using LayoutManager?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM