Android Navigation Architecture Component – Get current visible fragment

I managed to discover a way for now and it is as follows: NavHostFragment navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host); navHostFragment.getChildFragmentManager().getFragments().get(0); In case of course you know it is the first fragment. I am still investigating a way without this. I agree it is not the best way but that should be something for now.

Handling back button in Android Navigation Component

Newest Update – April 25th, 2019 New release androidx.activity ver. 1.0.0-alpha07 brings some changes More explanations in android official guide: Provide custom back navigation Example: public class MyFragment extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This callback will only be called when MyFragment is at least Started. OnBackPressedCallback callback = … Read more

Fragments destroyed / recreated with Jetpack’s Android Navigation components

Ian Lake from google replied me that we can store the view in a variable and instead of inflating a new layout, just return the instance of pre-stored view on onCreateView() Source: https://twitter.com/ianhlake/status/1103522856535638016 Leakcanary may show this as leak but its false positive..

Jetpack Compose – Order of Modifiers

There’s Layouts in Jetpack Compose codelab containing Layout modifiers under the hood step which explains the modifier order, see “Order matters” section. order matters when chaining modifiers as they’re applied to the composable they modify from earlier to later, meaning that the measurement and layout of the modifiers on the left will affect the modifier … Read more

Can I use library that used android support with Androidx projects.

You can enable Jetifier on your project, which will basically exchange the Android Support Library dependencies in your project dependencies with AndroidX-ones. (e.g. Your Lottie dependencies will be changed from Support to AnroidX) From the Android Studio Documentation (https://developer.android.com/studio/preview/features/): The Android Gradle plugin provides the following global flags that you can set in your gradle.properties … 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