I'm taking a course on Android and we have a task, one of them is to make a program called "MyBrowser" that they provide to us to be able to appear in the chooser if another program sends an implicit intent, I have researched and found this:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="andoid.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent-filter>
The first intent filter was already in the file and I have added the second one, but it doesn't work and I don't really understand why, the implicit intent goes like this:
private void startImplicitActivation() {
Uri webpage = Uri.parse("http://www.google.com");
Intent baseIntent = new Intent (Intent.ACTION_VIEW, webpage);
Intent chooserIntent = Intent.createChooser(baseIntent, "Choose application");
startActivity(chooserIntent);
}
That is the only intent that I've tried to open.
Thanks in advance.
Ok, I decided to copy paste the intent filters from the android browser and it worked, later I just started deleting random sets of < intent-filter> ... < /intent-filter> untill it stopped working and was left with this, now it works:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>