compose-destinations: [BUG] Launching explicit deep link caused duplicate of Activity

I have this composable inside MainActivity

@Destination(deepLinks = [DeepLink(uriPattern = "appname://notifications")], navGraph = "main")
@Composable
fun NotificationScreen(navigator: DestinationsNavigator) {}

Then I’m trying to launch show a notification with an intent containing explicit deep link as taught by the official documentation

val intent = Intent(Intent.ACTION_VIEW, "appname://notifications".toUri(), this, MainActivity::class.java)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
// then show notification as usual

This is what happens when I click the notification:

  1. It starts a new MainActivity (I know this is new because the splash screen showed up)
  2. It opens the correct destination
  3. But when I press back I get the home screen twice (another sign of duplicate activity)

This is my manifest:

        <activity
            android:name=".ui.MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.SplashScreen"
            android:windowSoftInputMode="adjustResize"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@winechitpaing-codigo Yes, I’ve been meaning to update it, thanks for reminding me! I’ll do it today 🙂

Yes that makes sense. I’ve tried all launch mode and intent flags to no avail. I think I should report this to the Google team.