user2999943 February 2016

Opening Android application from website not working

I want to implement such functionality in my simple Android app: when user visits a certain link (www.example.org let's say) in the web browser - Android OS should open my Android application if it is installed.

I tried to play with intent-filters like this:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">

        <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:host="example.org"
                android:pathPattern="/.*"
                android:scheme="http" />

            <data
                android:host="www.example.org"
                android:pathPattern="/.*"
                android:scheme="http"/>
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

But it's not working at all in google chrome mobile browser. In firefox, when I visit that link I get such Android icon on the right side of the search bar:

enter image description here

When I press that icon - my app opens. But still it is not what exactly I want to achieve.

Any idea why my code above doesn't work? I tried many variations of intent-filter declarations which I found on internet but nothing seem to work. I have nexus 5 device with Android 6 installed.

Answers


NeTeInStEiN February 2016

Try it like this, removing the path pattern:

<intent-filter>
    <data android:scheme="http" android:host="twitter.com"/>
    <action android:name="android.intent.action.VIEW" />
</intent-filter>

More info: Launch custom android application from android browser


Dalma Racz February 2016

<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:host="example.org"
            android:scheme="http" />
</intent-filter>


user2999943 February 2016

I have found a solution to my problem. Whole internet is full of old examples.

Since chrome version 25, google made slight changes in app deep linking functionality. More info: https://developer.chrome.com/multidevice/android/intents

So my working code looks like this:

Intent filter in Android side:

<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:host="launcher"
                android:path="/"
                android:scheme="test" />
        </intent-filter>

Web page html:

<a href="intent://launcher/#Intent;scheme=test;package=com.example.gediminas.myapplication;end">Launch app</a>

Post Status

Asked in February 2016
Viewed 3,889 times
Voted 6
Answered 3 times

Search




Leave an answer