I solve the problem with deep linking in the android application, after clicking on the link, the application should open and some action should be performed. As a result, I found a solution - for the activation, the manifest specifies an intent filter with the required domain and prefix, with the result that the activation is registered on the device as capable of handling a click on a link with a specific domain, like this:

<activity android:name=".MyActivity" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize"> <intent-filter> <category android:name="android.intent.category.BROWSABLE" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="{host}" android:pathPrefix="{path_prefix}" android:scheme="http" /> </intent-filter> </activity> 

Everything works fine, but I noticed that a new instance of this activity is opening. In this application, deep linking is used for authorization by clicking on a link from a letter. That is, at a certain step, the user minimizes the application, opens the mail, clicks the link, and receives a new activation instance when the previous one exists. In order to be absolutely clean, you must either close the not-killed activit when you click on the link, or open not a new activation instance, but deploy the existing one if it exists. Is there a way to make such a check from the opening activity?

    1 answer 1

    You can add the parameter android:launchMode in the manifest. There are 4 options, but you need singleInstance . May suit singleTask . It works like this: if an activation instance does not exist, then a new one is created, and if it does, then this activity is simply pushed upward.
    There is a nuance with obtaining data from the intent. The onNewIntent method has been onNewIntent in which a new intent will come, which will onNewIntent (eject) the current instance of the activation.

    Read more here.

    • My problem is partially solved, but only partially, because I cannot get data from the intent. getIntent (). getData () returns null. Tried to catch onStart, onRestart and onResume - iamthevoid
    • one
      What about onNewIntent ? - andreich
    • you can still simply setIntent(intent); in the onNewIntent method setIntent(intent); where intent is a parameter of the method onNewIntent - onNewIntent