问题
I have implemented deeplinking in one for my activities. But when the link is clicked, an Intent chooser opens asking whether to open from the app or from the browser. How to open from app directly?
Also, when the app is not installed, it does not take to playstore. It opens in the browser.
Below is my code in the manifest :
<activity android:name=".activities.VideoNewsDetailActivity"
android:theme="@style/AppThemeActivity"
android:configChanges="orientation|screenSize"
>
<!-- Add this new section to your Activity -->
<intent-filter android:label="@string/videoNewsDetail">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Handle urls starting with "http://www.example.com/products" -->
<data android:scheme="http"
android:host="ddnews.apprikart.in"
android:pathPrefix="/videos" />
<!-- Handle local urls starting with "example://products" -->
<data android:scheme="ddnews.apprikart"
android:host="videos" />
</intent-filter>
</activity>
回答1:
This is how intent filter work. If more than 1 app can handle your intent, it will show an intent chooser. It's up to the user whether they want to open the link in your app or browser.
Your server should handle the playstore redirection part. For example your deeplink url is http://www.example.com/page/1. Now when the app is not installed the server can check if the url is called from a browser, then it should redirect the browser to the playstore's app url.
回答2:
@Eric B. is right.
Even if you want only your app can open that link then you need to use custom scheme in intent-filter
, like:
android:scheme="ddnews"
And need to build link like, ddnews://domain.com/dir/page.html
来源:https://stackoverflow.com/questions/41458390/deeplink-on-click-opens-intent-chooser-in-android