Reputation: 536
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
This is my code:
//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);
}
Upvotes: 4
Views: 2477
Reputation: 10959
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>
Upvotes: 2