lundi 8 février 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.




Aucun commentaire:

Enregistrer un commentaire