How to prevent deep linking from mobile site in android?

流过昼夜 提交于 2019-12-20 07:18:18

问题


I have added deep links to all of my activities like this.

          <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.BROWSABLE"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <data
              android:host="www.example.com"
              android:path="/stores"
              android:scheme="https" />
          </intent-filter>

This works fine when I am calling within app using uri like this:

android-app://com.example.app/https/www.example.com/stores

But when I am visiting mobile site to this pages it gives me multiple options to open page in app or browser: https://www.example.com/stores. I have some pages which show only when user is logged in but if user logins from mobile site it will redirect to app and it breaks. I don't want to use custom schema.


回答1:


you need to check login status of the user in the entry point of your activities and show the login activity (or dialog) to them if they are not logged in.

you must handle this yourself in your different activities. which re available through deep linking. just check the logged in status each time these activities open and direct to login activity or dialog in the case they need.

if you dont want your browser to add your your application in the list of URI intent suggestions, just delete the "browsable" like below:

   <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT"/>
      <data
          android:host="www.example.com"
          android:path="/stores"
          android:scheme="https" />
      </intent-filter>


来源:https://stackoverflow.com/questions/40057244/how-to-prevent-deep-linking-from-mobile-site-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!