android-jetpack

Navigation Component: how to navigate from activity to a fragment

做~自己de王妃 提交于 2021-02-19 03:02:32
问题 I want to navigate on click FAB in (activity) to New fragment 1. in my code fab button in the main activity common for all pages. could anyone guide me? activity.xml <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools

How to Pass POJO class in Work manager in android?

ぐ巨炮叔叔 提交于 2021-02-18 09:58:46
问题 How can we pass Serializable object in work manager by setData method of work manager? Is there any way to process with Work manager by passing object? WorkManager is a library used to enqueue work that is guaranteed to execute after its constraints are met. WorkManager allows observation of work status and the ability to create complex chains of work. Map<String, Object> map = new HashMap<>(); AddressBookData addressBookData = new AddressBookData(); addressBookData.setThreadId(001); map.put(

Does Android Jetpack require the use of the Kotlin language?

雨燕双飞 提交于 2021-02-16 10:01:58
问题 I can't seem to find a clear answer to this in Google, and all the documentation and samples I've seen for Jetpack seem to refer to and use Kotlin. But do you HAVE to use Kotlin in order to use Jetpack? Or can Jetpack be used with traditional Java programs? I was looking at Kotlin but it adds almost a MB to your app size. And seeing as my entire app is only about 200KB currently, I don't think Kotlin is worth increasing the size of my app by 500%! 回答1: Jetpack is a collection of libraries

BottomNavigation Menu with Jetpack Navigation does not navigate

旧巷老猫 提交于 2021-02-11 17:36:06
问题 I have a strange problem regarding a BottomNavigationBar which I could not solve altough having spent a huge amount of time into it. When I use it in the 'recommended' way (from many tutorials) it just does not navigate. So what do I mean by 'recommended' way: I have a single acticity with a navHostFragment called 'MainActivity'. This main activity has a XML layout file in which I put the BottomNavigationBar. The BottomNavigationBar also has a XML layout file. Now I have a Fragment called 'FR

How to add animation transition to NavigationUI in android?

元气小坏坏 提交于 2021-02-11 07:19:22
问题 i'm using NavigationUI to tie destinations to menu items, but how to override the default animation transition? Based on the doc https://developer.android.com/topic/libraries/architecture/navigation/navigation-ui#Tie-navdrawer, i cant find any method that can add the animation transition. 回答1: NavigationUI does not offer that API. However, there's absolutely no requirement to use NavigationUI - it is only optional helper methods. Therefore you can copy / build a simplified version of what it

How to add animation transition to NavigationUI in android?

ぐ巨炮叔叔 提交于 2021-02-11 07:17:58
问题 i'm using NavigationUI to tie destinations to menu items, but how to override the default animation transition? Based on the doc https://developer.android.com/topic/libraries/architecture/navigation/navigation-ui#Tie-navdrawer, i cant find any method that can add the animation transition. 回答1: NavigationUI does not offer that API. However, there's absolutely no requirement to use NavigationUI - it is only optional helper methods. Therefore you can copy / build a simplified version of what it

Android Architecture Components - communication between Activity/Fragment and Service/IntentService

故事扮演 提交于 2021-02-08 02:56:51
问题 The answer to this question is providing me with a marvelous guide to how to use services in the Android Architecture Components/Jetpack environment. It suggests that IntentServices should just plug into ViewModels via Repositories, as if they were any other data source, like a web service. But neither that answer nor the Jetpack guide upon which it's based have much information about the so-called "Remote Data Source" object that would start and bind to the service, observe its LiveData and

Android Jetpack Navigation How to handle the Toolbar and BottomNavBar content

陌路散爱 提交于 2021-02-07 11:21:49
问题 I am a bit confused on how the Navigation component fits in the app behavior. It all looks nice and shiny in tutorials where you don't do things too complex but when implementing in real app, things seem different. Before Navigation Before implementing navigation I had to manually run fragment transactions. In order to do this, my fragment would implement an interface onFragmentAction which passed a bundle to the main Activity and in the activity based on the actions, replace the current

onActivityCreated deprecation : how to add fragments as observers of MainActivity using NavigationComponent

风流意气都作罢 提交于 2021-01-29 12:37:47
问题 I just saw that onActivityCreated() is going to be deprecated in future. I try to implement LifecycleOwner and LifecycleObserver pattern but I'm not quite sure about what I'm doing here. I'm using NavigationComponent, which meens : I have a MainActivity I have a MainFragment, instanciated as the home fragment I have multiple fragments that can be accessed from this home fragment For some reasons I need to know when activity is created from all of these fragments (MainFragment and sub

Could not resolve androidx.drawerlayout:drawerlayout:1.0.0

筅森魡賤 提交于 2021-01-29 09:22:58
问题 After updating my android studio from 3.3 to 3.4 I am now getting this error. ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0. Show Details Affected Modules: app ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0. Show Details Affected Modules: app ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath':