android-jetpack

Android navigation components with deep link: onNewIntent called multiple times

荒凉一梦 提交于 2020-07-22 08:29:44
问题 This time I need your help regarding the use of android navigation components with deeplink. I have been following this documentation and the connection between fragment and deeplink is working fine. The problem comes in regards to the activity that is receiving the deeplink. In my case, I set the android:launchMode="singleTask" <activity android:name=".features.welcome.WelcomeActivity" android:launchMode="singleTask"> <nav-graph android:value="@navigation/welcome_nav_graph" /> </activity>

How to pass a List as an argument to a Fragment using Navigation Component safeargs

て烟熏妆下的殇ゞ 提交于 2020-07-20 09:42:51
问题 The documentation discusses how to send simple integers and strings. For example: <argument android:name="myIntArg" android:defaultValue="255" app:argType="integer" /> In the origin Fragment: val action = OriginFragmentDirections.myAction(myInt) findNavController().navigate(action) In the destination Fragment: val receivedInt = DestinationFragmentArgs.fromBundle(arguments).myIntArg But say instead of myIntArg , I wanted to send a list of integers ( myIntListArg ). How would I do that? What

How to reduce time of PeriodicWorkManager in WorkManager

大兔子大兔子 提交于 2020-07-18 21:19:24
问题 In PeriodicTimeRequest minimum periodic time is 15 minute. I want to reduce it from 15 min to less than 15 minute.How can i do that? 回答1: You can not change the minimum time of 15 minutes. If it can be changed to less than that then it would not be called minimum. Depending on your need try using Alarm Manager or FCM. Refer to the following link for more details: https://developer.android.com/training/efficient-downloads/regular_updates 回答2: No, You cannot reduce the time to less than

Navigation DESTINATION_NAME is unknown to this NavController, ReOpening fragment previously closed using navController.popBackStack()?

允我心安 提交于 2020-07-18 10:19:12
问题 I am using Navigation Component in my app , recently it was working correctly but after updating project to AndroidX I am getting error navigation destination DESTINATION_NAME is unknown to this NavController only if that destination(Which I'm going to open) is previously closed from itself using navController.popBackStack() . Also, There is no error if I close DESTINATION fragment from MainActivity , But Error only Occurs fragment is closed from itself using popBackStack . like below

Safeargs library doesnt generate direction class

天涯浪子 提交于 2020-07-17 09:20:54
问题 I use navigation library and safeargs for passing data. I define argument to fragment like that. <fragment android:id="@+id/otherFragment" android:name="com.asd.navigate.OtherFragment" android:label="OtherFragment"> <argument android:name="screenTitle" android:defaultValue="0" app:type="string" /> </fragment> OtherFragmentArgs generated, I can use it but OtherFragmentDirection class doesnt generate when I click "make project". Is that bug or I have to do something different. Thnx for advice.

What is the Jetpack Compose equivalent of RecyclerView or ListView?

巧了我就是萌 提交于 2020-07-09 14:34:05
问题 In Jetpack Compose, how can I display a large list of data while laying out only the visible items, instead of composing and laying out every item on the initial layout pass? This would be similar to RecyclerView and ListView in the View toolkit. One could use a for loop to place all of the components inside of a Column in a VerticalScroller , but this would result in dropped frames and poor performance on larger numbers of items. Note: this is intended as a canonical self-answered question

What is the Jetpack Compose equivalent of RecyclerView or ListView?

微笑、不失礼 提交于 2020-07-09 14:33:09
问题 In Jetpack Compose, how can I display a large list of data while laying out only the visible items, instead of composing and laying out every item on the initial layout pass? This would be similar to RecyclerView and ListView in the View toolkit. One could use a for loop to place all of the components inside of a Column in a VerticalScroller , but this would result in dropped frames and poor performance on larger numbers of items. Note: this is intended as a canonical self-answered question

androidx.navigation.fragment.NavHostFragment is not accessible from xml file

人走茶凉 提交于 2020-07-09 13:28:47
问题 I am trying to use androidx navigation with bottom navigation view.So when i put fragment with android:name = "androidx.navigation.fragment.NavHostFragment" in xml file it gives me an error. I guess that xml doesn't see this library or this Fragment Here is xml file : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout

Cannot create instance of viewmodel after using Hilt in Android

南笙酒味 提交于 2020-07-07 10:32:40
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext

Cannot create instance of viewmodel after using Hilt in Android

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-07 10:32:32
问题 Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewModel() { } Here is PdfItemRepository class. @Singleton class PdfItemRepository @Inject constructor(private val pdfItemDao: PdfItemDao){ } For pdfItemDao . I created a module named DatabaseModule . Below is the code - @Module @InstallIn(ApplicationComponent::class) object DatabaseModule { @Provides fun provideDatabase(@ApplicationContext