【发布时间】:2016-08-24 04:02:56
【问题描述】:
我的操作栏上有一个操作按钮,单击时会打开一个固定的 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);
}
【问题讨论】:
-
为什么我的投票被否决了?
-
相信你的答案就在这里stackoverflow.com/questions/16932036/…
-
不,这不是我要找的。span>
-
我认为你没有完全理解这个问题
-
好的.. 这个怎么样? stackoverflow.com/questions/10972404/…