4

I'm trying to add deep-link to my app, the user does some stuff then the browser launches then getting back to the app by clicking on a button, the problem is that I need to resume the activity and not start it again. I tested the deep link by a script in adb shell and it is working fine but not from the browser.

here is how my code looks like:

<activity
        android:name=".activity.MapsActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="me"
                android:host="test" />
        </intent-filter>

</activity>

adb script:

adb shell am start -W -a android.intent.action.MAIN -d "me://test" com.example.myapp

HTML:

<a href="intent://test/#Intent;scheme=me;action=android.intent.action.MAIN;package=com.example.myapp;end">Back To App</a>

1 Answer 1

1

Add a launchMode to this activity with 'singleInstance'

<activity
    android:name=".activity.MapsActivity"
    android:label="@string/title_activity_maps"
    android:launchMode="singleInstance">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="me"
            android:host="test" />
    </intent-filter>

1
  • I think "singleTask" is better choice instead of "singleInstance" Feb 11, 2022 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.