I have to support deep link in my app. I have a de...
# android
r
I have to support deep link in my app. I have a deep link activity ( transparent activity) where I have all the re routing logic. The app uses navigation architecture component. But building back stack seems to be a problem. Since we have activities and some fragments. If I deep link to a activity hosting one fragment when app is not opened on clicking back the app exits. There is no other activity in the stack. I do understand that if you have all fragments and you deep link to fragment navigating up will take you to the start destination in nav graph. Is there a way to keep the existing code base and still have a proper back stack.
😶 1
Explicit deep link using pending intent
i
Explicit deep links also handle parent activities (starting the whole chain of activities when you deep links). Did you declare the correct parent activity in your manifest? https://developer.android.com/training/appbar/up-action#declare-parent
r
Thanks for the reply! let me check.
Yes i have declared the parent activity in manifest file
Copy code
<activity
        android:name=".ui.profile.ProfileActivity"
        android:screenOrientation="portrait"
        android:parentActivityName="com.peoplemesh.now.ui.MainActivity" >

    <!-- Parent activity meta-data to support 4.0 and lower -->
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.peoplemesh.now.ui.MainActivity" />
</activity>
Copy code
val pendingIntent = NavDeepLinkBuilder(this)
    .setGraph(R.navigation.profile_nav)
    .setDestination(R.id.profileFrag)
    .setArguments(bundle)
    .setComponentName(ProfileActivity::class.java)
    .createPendingIntent()

pendingIntent.send(0)
I expect the on deep link click navigate to profile screen on up navigation navigate to mainactivity.
Copy code
navController.setGraph(R.navigation.profile_nav, bundle)

val appBarConfiguration = AppBarConfiguration(
    topLevelDestinationIds = setOf(),
    fallbackOnNavigateUpListener = ::onSupportNavigateUp
)

mBinding.toolbar.setupWithNavController(navController, appBarConfiguration)
This is the ProfilrActivity where toolbar is set up.
MainActivity -> ProfileScreen -> up navigate -> back to MainActivity ( this flow works fine)
Deep link to ProfileActivity -> up navigate -> closes app ( since there is not activity in stack).
Am i missing anything here?
Also since this is not related to kotlin i can create a stackoverflow question with more details in case that's helpful.
@Ian Lake has the above anything to do with https://issuetracker.google.com/issues/142379671?pli=1
136 Views