android-navigation

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

singleTask launchMode in android not working

烈酒焚心 提交于 2021-02-18 11:27:31
问题 So, I have 4 activities Activity Activity1 , Activity2 , Activity3 and Activity4 . I start from Activity1 then on some event I start Activity2 then on some event on Activity2 I start Activity3 as a new task as public void onClick(View v) { Intent intent = new Intent(Activity2.this, Activity3.class); intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } Here Activity2 launchMode is decalared as singleTask. Then I navigate from Activity3 to

Z-Index conflict when animating fragment transition using the Android Navigation component

允我心安 提交于 2021-02-07 03:44:27
问题 I'm trying to use Android Navigation instead of fragment transaction. There is one problem however which is starting to be cumbersome. Upon using a slide-in animation for the Enter Animation the new fragment goes beneath the current fragment. Be sure to check the following video to see the bug in action. https://youtu.be/gFnXiEyiypM The bug seems not to be from the Navigation component though the hacky solutions (this and this) which have been introduced for this specific problem doesn't seem

Z-Index conflict when animating fragment transition using the Android Navigation component

二次信任 提交于 2021-02-07 03:42:38
问题 I'm trying to use Android Navigation instead of fragment transaction. There is one problem however which is starting to be cumbersome. Upon using a slide-in animation for the Enter Animation the new fragment goes beneath the current fragment. Be sure to check the following video to see the bug in action. https://youtu.be/gFnXiEyiypM The bug seems not to be from the Navigation component though the hacky solutions (this and this) which have been introduced for this specific problem doesn't seem

Android navigation component - change root fragment?

纵饮孤独 提交于 2021-02-05 06:48:21
问题 let's say I have fragments a->b->c , but "a" is a splash screen, so I want "b" to become first fragment in stack and throw "a" forever, so when I'm i "b" and press "back" system button - I close the app In SupportFragmentManager I used replace() and that worked. But how can I achieve it here? 回答1: here is an example graph.xml <?xml version="1.0" encoding="utf-8"?> <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns

Check if the navigation bar is hidden with ADB command “overscan”

北城以北 提交于 2021-01-29 22:04:09
问题 Many popular third parties apps and users are hiding the navigation bar by using a particular ADB command : adb shell wm overscan 0,0,0,-202 The particular thing of this command is if you check the presence of the navigation bar by reading a boolean from Android resources it will always return true (navigation bar is not hidden). That tricky ADB command doesn't hide the navigation bar it just moves it off the screen. Is there a way to detect this? 来源: https://stackoverflow.com/questions

Database Dependent (Room) Conditional startDestination Android Navigation

我的未来我决定 提交于 2021-01-29 11:23:18
问题 I'm setting a conditional startDestination, as e.g. seen here: https://stackoverflow.com/a/51961843/393607 The problem: The condition should depend on a room query. This query can't be run on the main thread of course, the onCreate of the MainActivity would have to wait for the query to be finished before constructing the navigation graph. Any recommendations on how to go about this? 回答1: Ok that was fast. Kotlin's really great: wrapping everything in runBlocking {} did the trick. I'll leave

java.lang.IllegalArgumentException: navigation destination {actionId} is unknown to this NavController when Activity is recreated?

有些话、适合烂在心里 提交于 2021-01-29 05:06:23
问题 I am coming from reading all the answers in IllegalArgumentException: navigation destination xxx is unknown to this NavController with no luck. I am getting this when the activity is recreated from either a manual recreate() call or coming back from a process death. I have an Activity that changes its Fragments using Navigation . Fragment A has a FAB that navigates to Fragment B when clicked. floatingActionButton = view.findViewById<FloatingActionButton>(R.id.floating_action_button).apply {

How to work with preference in single activity design using navigation component?

◇◆丶佛笑我妖孽 提交于 2021-01-28 06:20:27
问题 I want to migrate to single activity design using navigation component. I am using one activity and others are fragment. For some screens, I have only layouts, no preference. No problems to inflate those in fragment. But i faced problem when i try to work with preference. My requirements is: I need to inflate a toolbar and preference list in a fragment. My approaches: Add preference using this following code. SettingFragment.java @Override public void onCreatePreferences(Bundle

is it normal if my image from camera in ImageView disappear after segue to another fragment using navigation component?

☆樱花仙子☆ 提交于 2021-01-25 01:58:19
问题 I try to capture an image using camera then the image result will be placed on my ImageView in a fragmentA like the code below, so it it NOT fetching an image path from Server then place it in ImageView using Glide Library, I take an image from camera. val image_uri = Uri.fromFile(photoFile) photoImageView.setImageURI(image_uri) and then, I move to next destination using this code (from fragmentA to fragmentB) val toFragmentB = AFragmentDirections.actionGlobalBFragment() findNavController()