Question

My app has an activity with the following intent filter.

<intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:host="m.testsite.com"> </data>
            <data android:scheme="http"></data>
            <data android:pathPattern=".*"></data>
 </intent-filter>

This opens up any link with the url http://m.testsite.com/anypath in the app . However sometimes it so happens that there is no data inside the app with respect to the path and I need to transfer him back to the browser only.

What should be the intent-filter for this?

Edit:-Seems like my question was not very clear .The device had two packages listening to the same intent-filter. One was the browser and the other was my app. I was in a situation where in certain cases, I had to target only the browser and not the app for the same intent-filter. I was hoping that there would be some particular action or category which I could target for just the browser alone. However I managed to solve it . I have put my answer below.

Was it helpful?

Solution

This is how I solved it finally:-

for (ResolveInfo resolveInfo : list) {
     if (!activityName.contains("MyApplicationActivity")) {
                   browserIntent =
                           packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName);
                    ComponentName comp =
                            new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);

                    browserIntent.setAction(Intent.ACTION_VIEW);

                    browserIntent.setComponent(comp);
                    browserIntent.setData(data);
                    startActivity(browserIntent);
                    break;
                }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top