简体   繁体   中英

How to start my Android application when a link clicked from external app like whatsapp or facebook?

I have used deep linking concept using following intent filter in manifest file.

<activity
        android:name=".MyActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateAlwaysHidden" >
        <intent-filter android:label="@string/app_name">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="test.myapp.com"
                android:scheme="http"
                />
        </intent-filter>
    </activity>

This helps me to show my application when clicked on link in whats app, but it shows other applications in list like chrome,Internet etc. How can I make only to access my app directly after clicking link in other application like whats app.?

My only idea is to add an intent filter, that starts your app if the device opens a special URL (for example www.your-project.com). Have a look on this documentation it explains all social sites linkage to your app.

If the user has your app installed, a click on the link will open your app. Otherwise the link will be opened by your default browser.

What you want to achieve is only possible from Android 6.0 , in Android 6.0 you can bypass the Intent chooser dialog and directly launch your application on clicking on the link.

To do this, please check on this App link documentation. They have explained very well how to do it

and also you may have to make slight modifications in the intent filter as shown below by adding parameter android:autoVerify="true"

<activity ...>

<intent-filter android:autoVerify="true">
    <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="www.example.com" />
    <data android:scheme="https" />
</intent-filter>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM