Questions tagged [android-jetpack]

Android Jetpack is a Google's set of libraries, tools and architectural guidance to build Android apps and provides common infrastructure code.

Android Jetpack is the next generation of Android components, bringing together the benefits of the Support Library -- backwards compatibility and immediate updates -- to a larger set of components, making it quick and easy to build robust, high quality apps.

It manages activities like background tasks, navigation, and lifecycle management, so you can eliminate boilerplate code and focus on what makes your app great.

It is designed to work well with Kotlin, saving you even more code with Android KTX. The new Android Jetpack components released today include WorkManager, Paging, Navigation, and Slices.

Useful Links

2879 questions
95
votes
5 answers

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

I am using Navigation from Android Jetpack to navigate between screens. Now I want to set startDestination dynamically. I have an Activity named MainActivity And two Fragments, FragmentA & FragmentB. var isAllSetUp : Boolean = // It is dynamic and…
95
votes
8 answers

How to change start destination of a navigation graph programmatically?

Basically, I have the following navigation graph: I want to change my starting point in navigation graph to fragment 2 right after reaching it (in order to prevent going back to fragment 1 when pressing back button - like with the splash…
92
votes
2 answers

Android Jetpack Compose Icons doesn't contain some of the material icons

There're many oft-used material icons in androidx.compose.material.icons.Icons but some are missing. Just as an example there is no print icon. ... import androidx.compose.material.Icon import androidx.compose.material.icons.Icons import…
Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123
89
votes
6 answers

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

I been struggling a lot thinking about where to place Android Services in the new Android recommended Architecture. I came up with many possible solutions, but I cannot make up my mind about which one is the best approach. I did a lot of research,…
88
votes
16 answers

Dynamic ActionBar title from a Fragment using AndroidX Navigation

I am using the new Navigation component from Android Jetpack. The root Activity setup is quite simple: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) …
Jonas Schmid
  • 5,360
  • 6
  • 38
  • 60
81
votes
3 answers

Android. Is WorkManager running when app is closed?

I want to schedule nightly database updates. So I use new Android WorkManager. My understanding is that once scheduled it will always run in the background independently from the app's lifecycle. Is that right? My first tests show that Work is only…
80
votes
6 answers

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

I'm new in jetpack compose and trying to understand the difference between remember and mutableStateOf In other words the deference between this line val text = remember{ mutableStateOf("") } and this val text = remember{ "" } and this also val…
Ahmed Abdalla
  • 2,356
  • 2
  • 14
  • 27
79
votes
3 answers

When should I use Android Jetpack Compose's Surface composable?

There's a Surface composable in Jetpack Compose which represents a material surface. A surface allows you to set up things like background color or border but it seems that the same might be done using modifiers. When should I use the Surface…
Valeriy Katkov
  • 33,616
  • 20
  • 100
  • 123
79
votes
6 answers

New navigation component from arch with nested navigation graph

I have one case and wish to implement it by arch navigation component. For example I have 2 Nav Graphs (main and nested). Can I call main graph from nested and how?
78
votes
6 answers

Bottom Nav Bar overlaps screen content in Jetpack Compose

I have a BottomNavBar which is called inside the bottomBar of a Scaffold. Every screen contains a LazyColumn which displays a bunch of images. For some reason when I finish scrolling, the BottomNavBar overlaps the lower part of the items list. How…
Gianluca Veschi
  • 1,239
  • 1
  • 14
  • 20
75
votes
9 answers

How to upgrade an Android project to Java 11

I am using the latest Android Studio Arctic Fox 2020.03.01 Canary 8 and AGP 7, and I want to convert my project to use Java 11. Apparently just doing the following does not work as mentioned on…
75
votes
10 answers

What exactly is Android Jetpack?

I've seen the developer keynote of Google I/O 2018, and I've read the jetpack homepage on Android developer website, but I cannot make sense of what it actually is. To me it seems like just a new name for a bunch of APIs we already use. Is there…
ishaan
  • 1,951
  • 1
  • 19
  • 31
74
votes
8 answers

Navigation popUpTo and PopUpToInclusive aren't clearing the backstack

I'm new to the Android Jetpack Navigation architecture. I'm trying it out on a new app. There's one activity and a few fragments, two of them are login screen and email login screen. I defined those fragments in my navigations XML. The flow of the…
adrilz
  • 785
  • 1
  • 5
  • 10
72
votes
10 answers

Navigation Architecture Component - Dialog Fragments

Is it possible to use the new Navigation Architecture Component with DialogFragment? Do I have to create a custom Navigator? I would love to use them with the new features in my navigation graph.
71
votes
6 answers

How to create rounded border Button using Jetpack Compose

I need to add border with rounded corner in Button using Jetpack Compose Like :