0

When I use custom scheme (for example myhttp) everything works as I expected, but if I use http , it does not handle, and every time browser opens the host (eg:192.168.1.111).

How can I solve this problem?

my manifest.xml

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

my activity:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    Log.i("MyTAG", "here--01");
}

1 Answer 1

1

Give your intent filter a higher priority than the default browser:

http://developer.android.com/guide/topics/manifest/intent-filter-element.html#priority

    <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"/> 
        <data android:host="192.168.1.111"/>
        <android:priority="999"/>
    </intent-filter>

It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)

The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.


Also if you are dealing with your browser. At one time you may have set Chrome as the default app to open this intent. So you would have to reset this.

Goto Settings > Apps > Chrome (or Firefox or w/e) > Clear defaults

clear defaults


You can use an app called Default App Manager to check what defaults you have set

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for reply, but unfortunately it has same result. I tried, chrome and firefox.
I looked settings, but there is no default settings, therefor it buttons are disabled. After your comments, when I press my custom url as a long time. The browser suggest me, open with MyApp as secondly.
When I clicked in chrome browser, it suggest one-time or every time. After selecting every time, it worked. But the problem continues for firefox, this not important for me. Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.