Navigation popUpTo and PopUpToInclusive aren’t clearing the backstack

<action android:id=”@+id/action_login_to_emailLoginFragment” app:destination=”@id/emailLoginFragment” app:popEnterAnim=”@anim/slide_in_right” app:popExitAnim=”@anim/slide_out_right” app:popUpTo=”@+id/loginFragment” app:popUpToInclusive=”true”/> Your popUpTo is going back to the email login, and then popping it because of the inclusive. If you will change the popUpTo to your login fragment, it will be navigated back to, and popped as well because of the inclusive flag, which will result in your desired … Read more

What is the difference between “remember” and “mutableState” in android jetpack compose?

remember is a composable function that can be used to cache expensive operations. You can think of it as a cache which is local to your composable. val state: Int = remember { 1 } The state in the above code is immutable. If you want to change that state and also update the UI, … Read more

Navigation Architecture Component – Dialog Fragments

May 2019 Update: DialogFragment are now fully supported starting from Navigation 2.1.0, you can read more here and here Old Answer for Navigation <= 2.1.0-alpha02: I proceeded in this way: 1) Update Navigation library at least to version 2.1.0-alpha01 and copy both files of this modified gist in your project. 2) Then in your navigation … Read more

What exactly is Android Jetpack?

On its official site, it says: Android Jetpack is a set of libraries, tools and architectural guidance to help make it quick and easy to build great Android apps. It provides common infrastructure code so you can focus on what makes your app unique Technically, it is the support library, android-ktx and the Android Architecture … Read more

Android. Is WorkManager running when app is closed?

Based on various issues reported on the WorkManager bugtracker, their documentation is not completely precise about the exact behavior of the WorkManager in such edge cases. On certain devices, apps are force stopped when the app is cleared from task manager, so that part is expected. … source Unfortunately, some devices implement killing the app … Read more

How to disable ripple effect when clicking in Jetpack Compose

Short answer: to disable the ripple pass null in the indication parameter in the clickable modifier: val interactionSource = remember { MutableInteractionSource() } Column { Text( text = “Click me without any ripple!”, modifier = Modifier .clickable( interactionSource = interactionSource, indication = null ) { /* doSomething() */ } ) Why it doesn’t work with … Read more

New navigation component from arch with nested navigation graph

The point is to get the right NavController to navigate in the right graph. Let’s take this scenario as an example: MainActivity |- MainNavHost |- NavBarFragment | |- NestedNavHost | | |-NestedContentFragment1 | | |-NestedContentFragment2 | | | |- BottomNavigationView | |- LoginFragment The main graph and the nested graph are in separate xml files: … Read more

BoundService + LiveData + ViewModel best practice in new Android recommended architecture

Updated: After getting suggestion from @Ibrahim Disouki (Thank you for that) I dig deeper and found out something interesting! Here’s background. O.P. seeks for solution “Where Service component of Android Framework stands considering Android Architecture Components“. So, here’s out the box(SDK) solution. It stands at the same level as Activity/Fragment. How? If you’re extending Service … Read more

Dynamic ActionBar title from a Fragment using AndroidX Navigation

As of 1.0.0-alpha08, you can have the NavigationUI bits dynamically set the title… if the dynamic bits are arguments on the navigation action. So, for example, in your navigation graph, you could have something like this: <fragment android:id=”@+id/displayFragment” android:name=”com.commonsware.jetpack.sampler.nav.DisplayFragment” android:label=”Title: {title}” > <argument android:name=”modelId” app:argType=”string” /> <argument android:name=”title” app:argType=”string” /> </fragment> Here, the android:label attribute … Read more

Is it possible to set startDestination conditionally using Android Navigation Architecture Component(Android Jetpack)?

Finally, I got a solution to my query… Put below code in onCreate() method of Activity. Kotlin code val navHostFragment = (supportFragmentManager.findFragmentById(R.id.home_nav_fragment) as NavHostFragment) val inflater = navHostFragment.navController.navInflater val graph = inflater.inflate(R.navigation.nav_main) //graph.addArgument(“argument”, NavArgument) graph.setStartDestination(R.id.fragment1) //or //graph.setStartDestination(R.id.fragment2) navHostFragment.navController.graph = graph Java code NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.home_nav_fragment); // Hostfragment NavInflater inflater = navHostFragment.getNavController().getNavInflater(); NavGraph graph … Read more