I use the branch.io library to work with the app link. In the manifest, I specify the intent-filter for the Branch URI scheme:

<intent-filter> <data android:scheme="***" android:host="open" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> 

For App Links, the manifest states:

 <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="https" android:host="***.app.link" /> <data android:host="***-alternate.app.link" android:scheme="https"/> <data android:host="***.test-app.link" android:scheme="https"/> <data android:host="***-alternate.test-app.link" android:scheme="https"/> 

LaunchMode for AppLinkActivity is listed as singleTask. I initialize Branch in the Application class, in the onCreate method:

 Branch.getAutoInstance(this); 

When I open AppLinkActivity, I get an instance and initialize the session:

  Branch branch = Branch.getInstance(getApplicationContext()); branch.initSession((referringParams, error) -> { LogFileUtil.writeLog("Finish init session"); if (error == null) { //Кое что делаю } else { //Кое что делаю } }, this.getIntent().getData(), this); 

Now to the problem. When I open the application via the AppLink parameter, the referringParams is not empty and I can pull the data I need from it. But when my application is open and I click on AppLink'y from another application, then the parameter referringParams becomes empty. It seems to me that the point is branch initialization. How can this be corrected?

    1 answer 1

    The solution is to make the AppLinkActivity class the main one. Those. this activation should have one more intent-filter:

     <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter>