android-architecture-navigation

Navigating to preference fragment using navigation component

大兔子大兔子 提交于 2019-12-08 15:30:23
问题 I'm trying to migrate my medium sized app to the new Android navigation component. Currently, my app consists of the single activity and I'm planning on keeping it the same (for that matter); So, I'm facing this issue in which I have a settings fragment ( PreferenceFragment ) that can be navigated to, basically, from every other fragment. This navigation is made through a menu in the app bar, therefore onOptionsItemSelected (containing this navigation) is in the main activity. I'm having

Better way to pass data between Fragments Navigation Component?

非 Y 不嫁゛ 提交于 2019-12-08 09:13:36
问题 Passing data between Fragments in Navigation Component is easy. Say going from A to B you just set arguments with SafeArgs and you are done. But, it gets tricky when passing data from B back to A . According to documentation, we can use SharedViewModel which is works well. But I am looking for better way of passing data back to A from B . The problem of using SharedViewModel is, you have to create SharedViewModel for every fragment pair that you need to pass data. Any suggestions? If any

Unable to clear the back stack of all fragments with Navigation Components

倖福魔咒の 提交于 2019-12-07 13:11:49
问题 I am using the Android Navigation Components and am facing one weird issue. I am not able to clear the back stack for the up button, no matter what I tried. My Navigation graph looks like this: Let's take the LoginFragment for example, <fragment android:id="@+id/loginFragment" android:name="com.yashovardhan99.firebaselogin.LoginFragment" android:label="Login" tools:layout="@layout/fragment_login" > <action android:id="@+id/action_loginFragment_to_welcomeFragment" app:destination="@id

Navigation Component's popUpTo not removing up button

Deadly 提交于 2019-12-07 05:32:19
问题 I'm using the Navigation Architecture Component and I have a setup similar to this one for popping the stack when navigating to a particular fragment: <action android:id="@+id/navigate_to_main_screen" app:destination="@id/fragment_main_screen" app:popUpTo="@+id/navigation_main" app:popUpToInclusive="true"/> This works almost as expected. Both the system back button and the up icon in the app bar don't navigate to the previous fragment. The system back button exits the app. However, the up

Navigation Component prevent to recreate fragment on back press

陌路散爱 提交于 2019-12-07 03:58:48
问题 I'm using the Jetpack Navigation Component in my project with a signle activity and some fragments. I have a fragment with a list that fills from server side. I call getDataFromServer on onViewCreated method, then when a user clicked on an item new fragment shows. The problem is when I press the back button, onViewCreated calls again in my list fragment. so how can I prevent my first fragment to recreating again? I don't want to onViewCreated calls. 回答1: You can't prevent calling

Unable to clear the back stack of all fragments with Navigation Components

倖福魔咒の 提交于 2019-12-06 03:55:24
I am using the Android Navigation Components and am facing one weird issue. I am not able to clear the back stack for the up button, no matter what I tried. My Navigation graph looks like this: Let's take the LoginFragment for example, <fragment android:id="@+id/loginFragment" android:name="com.yashovardhan99.firebaselogin.LoginFragment" android:label="Login" tools:layout="@layout/fragment_login" > <action android:id="@+id/action_loginFragment_to_welcomeFragment" app:destination="@id/welcomeFragment" app:popUpTo="@+id/nav_graph" app:popUpToInclusive="true" /> </fragment> The Java code to

Proguard causing runtime exception with Android Navigation Component

荒凉一梦 提交于 2019-12-05 21:48:20
问题 I'm experiencing this crash when using proguard after integrating the NavigationComponent ( android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha01 ) into my project with target and compile sdk of 27 2018-05-16 12:13:14.044 24573-24573/com.mypackage.myapp.x E/AndroidRuntime: FATAL EXCEPTION: main Process: com.mypackage.myapp.x, PID: 24573 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mypackage.myapp.x/com.mypackage.myapp.MainActivity}: android.view

Send argument through PendingIntent of NavDeepLinkBuilder

空扰寡人 提交于 2019-12-05 19:00:18
I'm having some difficulties sending an argument through a PendingIntent of a notification using NavDeepLinkBuilder . I'm able to get the destination Activity to launch by clicking the notification, but the Activity 's Intent doesn't contain the argument value that I passed it through the NavDeepLinkBuilder . The Intent instead returns the defaultValue that I set in the nav graph - "noJobId". Notification creation : val notification = NotificationCompat.Builder(context, context.getString(R.string.notification_channel_id_new_job)) ... .setContentIntent( NavDeepLinkBuilder(context)

How do I link multiple activities in android navigation editor?

自古美人都是妖i 提交于 2019-12-05 14:51:19
问题 I'm learning android development and the navigation component, trying to link multiple activities as the document had written. But it seems like it's impossible to create action between two activities to a single navigation graph which was reasonable to me as the document had written. The NavController and its navigation graph is contained within a single activity. Therefore, when migrating an existing project to use the Navigation Architecture Component, focus on migrating one Activity at a

Navigation Component prevent to recreate fragment on back press

自古美人都是妖i 提交于 2019-12-05 08:11:33
I'm using the Jetpack Navigation Component in my project with a signle activity and some fragments. I have a fragment with a list that fills from server side. I call getDataFromServer on onViewCreated method, then when a user clicked on an item new fragment shows. The problem is when I press the back button, onViewCreated calls again in my list fragment. so how can I prevent my first fragment to recreating again? I don't want to onViewCreated calls. You can't prevent calling onViewCreated method or any method of your fragment when back button pressed so you should better use view model with