android - Set app activity to accept action.VIEW action -
when user tap on button code happen:
uri web = uri.parse("http://www.google.com"); intent = new intent(intent.action_view,web); startactivity(i);
and it's runs ok, open website in default web browser. trying display menu, appears if have more applications capable display web pages installed. prepared blank application fakebrowser androidmanifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pavel.fakebrowser" > <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".myactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> <intent-filter> <data android:scheme="http" android:host="google.com"/> <category android:name="android.intent.category.browsable" /> <action android:name="android.intent.action.view" /> </intent-filter> </activity> </application>
i try set second intent-filter tag, app accept browser request, it's still opens default browser. please can tell me, have wrong? thanks.
you have use intentchooser:
uri web = uri.parse("http://www.google.com"); intent = new intent(intent.action_view,web); startactivity( intent.createchooser(i, "choose program"));
more info: http://developer.android.com/training/basics/intents/sending.html
update: , on manifest:
<intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <data android:scheme="http"/> </intent-filter>
Comments
Post a Comment