[英]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.