Search code examples
androidandroid-intentandroid-activityandroid-manifestintentfilter

Web browser application - how to intercept URL intents?


I have a custom ROM and have no default browser except WebView Browser Tester. I have develop my own kind of web browser app(webviewclient activity) and install this in a phone. Now I want that whatever URLs when user click in a phone, my browser application will intercept and load this URL. Here is what I am using in intent_filter

 <intent_filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent_filter>

But it is not working and still WebView browser Tester app launch and loading links. Can someone tell me how I can set my app as a default browser App OR use any special intent which can help to launch this activity while clicking on any URL?


Solution

  • Try adding both intent filters

            <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"
                    android:host="*"/>
            </intent-filter>
            <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="https"
                    android:host="*" />
            </intent-filter>