[英]I don't want my app to appear on the chooser dialog when opening URL's
我在操作栏上有一个操作按钮,当单击该按钮时会打开一个固定的url,它可以正常工作,但是我不希望自己的应用程序出现在选择器对话框“使用完整操作”中,它应该只显示手机默认的浏览器(例如Chrome或Mozilla),实际上它似乎是Chrome和我的应用程序作为打开URL的选项。 我从这里实现了以下代码: http : //developer.android.com/intl/es/guide/components/intents-common.html
这是我的代码:
//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
@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);
}
从您的应用清单中删除此行。
<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" />
所以你的意图过滤器应该像
<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.