Questions tagged [android-components]

The Material Components for Android library helps developers execute Material Design

This tag is for questions about the Material Components for Android.
The Material Components for Android help developers execute Material Design. Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional Android apps.

Material Components for Android is a drop-in replacement for Android's Design Support Library.

52 questions
174
votes
11 answers

Android ViewModel additional arguments

Is there a way to pass additional argument to my custom AndroidViewModel constructor except Application context. Example: public class MyViewModel extends AndroidViewModel { private final LiveData> myObjectList; private…
Mario Rudman
  • 1,899
  • 2
  • 14
  • 18
23
votes
10 answers

Room cannot pick a constructor since multiple constructors are suitable error

I try to implement persistent library in my android kotlin project, but catch this error on compile time: error: Room cannot pick a constructor since multiple constructors are suitable. Try to annotate unwanted constructors with @Ignore. Error…
Gogi Bobina
  • 1,086
  • 1
  • 8
  • 25
17
votes
7 answers

Android Navigation Architecture Component - Nav Drawer Icons

I'm currently using the Android Architecture Component's Navigation, but I'm running into an issue with my Navigation Drawer. It shows the hamburger menu when at my starting destination, but other Fragments are showing the up arrow. I believe I've…
14
votes
4 answers

kotlin android start new service

By using the below code, I'm trying to start new service from a Broadcast receiver, but the service does not seem to start. What is the correct way to start a service in kotlin? val intent = Intent(context, LocationService::class.java) if (context…
Logo
  • 1,366
  • 2
  • 11
  • 16
10
votes
0 answers

List the fragments on the backstack when using Android's navigation component

I'm trying to debug some code and was hoping to list the fragments in the current backstack in Android. The stock solution is to simply list them from the support manager, so from a method within an activity : Log.i("fragments","Count : " +…
Carel
  • 3,289
  • 2
  • 27
  • 44
8
votes
1 answer

Insert an object inside an object using android room persistence library

Directory @Entity(tableName = "directory") class Directory(@PrimaryKey(autoGenerate = false) var id: Int? = null, @ColumnInfo(name = DIR_NAME) var dirName: String? = null, @Ignore var dirImages: List? =…
6
votes
2 answers

Material Design Components Site

Today I was Googling for "material design components" I ended up at this site: https://material.io/components/ As I remember, I've never seen it before. In the Android section there are instruction to use the components and ok, it seems to be the…
6
votes
4 answers

Android Studio 2.1.1 using tabs, not spaces, even though tabs are not checked in Settings

When editing Java files, if I'm at the end of the line and I type the Enter key, it starts the next line properly indented 4 columns, to match the line above. That's OK but it's indenting with a tab, not spaces, even though in…
4
votes
1 answer

Is there a way to define the starting tab in the navigation advanced sample?

I am working on the project NavigationAdvancedSample of the architecture-components-samples repository. This project shows a workaround to support multiple back stacks for each tab of a BottomNavigationView. In this configuration, you define a…
4
votes
1 answer

Android Components ViewModel across activitis

In Android Components could I make application class as the owner of ViewModel so I use it across several activities? or there no walk around? ViewModelProviders.of(application class not activity).get(MyViewModel.class);
amorenew
  • 10,760
  • 10
  • 47
  • 69
3
votes
3 answers

Viewmodel cannot create an instance of class Android Java MVVM

i'm trying to implement a movie app that allows brows movies and checkout the ratings on them... and i got a problem when i tried to implement a MVVM model with my MovieListViewModel where the debugger is telling me that i cannot create an instance…
ayman_rahmon
  • 140
  • 4
  • 10
3
votes
2 answers

How to show HomeAsUp when use Android navigation graph

I have a problem to show HomeAsUp . I think there is such as a way to link NavColtroller with ActionBar. so I don't need to adjust Toolbar manually for each Fragment, mainly when use inclusive return to previous screen.
3
votes
2 answers

Service is killed after a short period of time (1 minute)

I've created a service that its job is to clear the notifications when the app is closed by the user. Everything works perfectly well but sometimes when the application is in the background for more than 1 minute the service is killed (which means…
Kwnstantinos Nikoloutsos
  • 1,832
  • 4
  • 18
  • 34
2
votes
1 answer

is it necessary to unRegisterForActivityResult when start activity for result in android ? how manage different request codes?

I have two questions about registerForActivityResult call back in android. is it necessary to un register this call back when the activity is going to destroy? or this call back is lifeCycle aware and safe when it is going to use ? and the other…
2
votes
1 answer

Android Work Manager periodic work request not repeating when app is cleared from recents

I have implemented a periodic work request using android work manager, the work is getting repeated if app is in foreground or background. But when the app is cleared from recents, the work manager stops repeating the work. Is there a solution or…
1
2 3 4