android-jetpack

An Annotation argument must be a compile time constant

…衆ロ難τιáo~ 提交于 2019-12-01 18:08:56
i have seen this question. Similar error.But in my case it is different. While working with Room i was creating table. it was working fine. @Daointerface UserDao { @Query("SELECT * FROM user") fun getAll(): List<User> @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(user: User) @Delete fun delete(user: User)} but then i found all table Names must be stored in a different class. like table name "user" - > Stored in different class. Eg. class Table { companion object { const val USER_TABLE = "user" }} But below code is not working . it is not picking up table name from Table class.

WorkManager OneTimeWorkRequest InitialDelay works after twise the time set

为君一笑 提交于 2019-12-01 12:26:28
I'm facing problem with WorkManager OneTimeWorkRequest setInitialDelay . It's work fine when app is in forground or in recent list. But When I remove App from recent list everything is messed up. What I want to achieve ? - I want send notification to user after few hours when some task is pending ,so after some R&D start work using WorkManager because of It's ability to Schedule Tasks without background service limitation. Now below is code snippet which work till app is not removed from recent: Constraints constraints = new Constraints.Builder() .setRequiresBatteryNotLow(true) .build(); final

Two different menus for Top App Bar and Bottom App bar with Navigation Components

谁都会走 提交于 2019-12-01 04:38:02
I was trying out Android Navigation Architecture Component and was also looking into Material design guidelines. I really got inspired by the design below: For the top toolbar I can set it by setSupportActionBar(toolbar) and then in MainActivity : public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); return super.onCreateOptionsMenu(menu); } But while trying it out I cannot figure it out how to implement menus on both Top and Bottom app bars for different fragments, specially for bottom app bar. For example , I want to show a favorite icon on bottom app

Two different menus for Top App Bar and Bottom App bar with Navigation Components

最后都变了- 提交于 2019-12-01 02:16:37
问题 I was trying out Android Navigation Architecture Component and was also looking into Material design guidelines. I really got inspired by the design below: For the top toolbar I can set it by setSupportActionBar(toolbar) and then in MainActivity : public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); return super.onCreateOptionsMenu(menu); } But while trying it out I cannot figure it out how to implement menus on both Top and Bottom app bars for

An Annotation argument must be a compile time constant

為{幸葍}努か 提交于 2019-12-01 00:32:11
问题 i have seen this question. Similar error.But in my case it is different. While working with Room i was creating table. it was working fine. @Daointerface UserDao { @Query("SELECT * FROM user") fun getAll(): List<User> @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(user: User) @Delete fun delete(user: User)} but then i found all table Names must be stored in a different class. like table name "user" - > Stored in different class. Eg. class Table { companion object { const val USER

Periodic daily work requests using WorkManager

前提是你 提交于 2019-11-30 19:35:49
How to properly use the new WorkManager from Android Jetpack to schedule a one per day periodic work that should do some action on a daily basis and exactly one time? The idea was to check if the work with a given tag already exists using WorkManager and to start a new periodic work otherwise. I've tried to do it using next approach: public static final String CALL_INFO_WORKER = "Call worker"; ... WorkManager workManager = WorkManager.getInstance(); List<WorkStatus> value = workManager.getStatusesByTag(CALL_INFO_WORKER).getValue(); if (value == null) { WorkRequest callDataRequest = new

Navigation graph with multiple top level destinations

▼魔方 西西 提交于 2019-11-30 15:05:54
问题 I am implementing an android app (in Kotlin, but that is not relevant to the Problem) in my free time and I try to use android jetpack and new libraries. I have a single Activity with a navigation drawer. I try to follow the sample sunflower app. It uses the following combination in the main activity to enable the logic behind the navigation drawer: appBarConfiguration = AppBarConfiguration(navController.graph, drawerLayout) setSupportActionBar(findViewById(R.id.toolbar))

Navigation graph with multiple top level destinations

情到浓时终转凉″ 提交于 2019-11-30 13:01:13
I am implementing an android app (in Kotlin, but that is not relevant to the Problem) in my free time and I try to use android jetpack and new libraries. I have a single Activity with a navigation drawer. I try to follow the sample sunflower app . It uses the following combination in the main activity to enable the logic behind the navigation drawer: appBarConfiguration = AppBarConfiguration(navController.graph, drawerLayout) setSupportActionBar(findViewById(R.id.toolbar)) setupActionBarWithNavController(navController, appBarConfiguration) Note on this code : This automatically will navigate

Showing detailed progress for running WorkManager workers

感情迁移 提交于 2019-11-30 09:02:36
问题 I want to replace the job scheduling aspect of my existing data syncing system with the new JetPack WorkManager (link to codelabs) component (in a sandbox branch of the app). My existing system works well but some of the new features in WorkManager would come in handy (e.g. chaining). My current system uses a shared LiveData to communicate the progress from a job in progress to any UI element ( RecyclerView in my case) observing on it (I'm actually SwitchMapping in the ViewModel into a list

Navigation Architecture Component - Dialog Fragments

Deadly 提交于 2019-11-30 07:54:50
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. No, as of the 1.0.0-alpha01 build, there is no support for dialogs as part of your Navigation Graph. You should just continue to use show() to show a DialogFragment . MatPag May 2019 Update : DialogFragment are now fully supported starting from Navigation 2.1.0-alpha03 , 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