Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
It looks like this was fixed in
ap...@google.com <ap...@google.com> #3
For the avoidance of doubt, I think it's just the three lines in RemotePlaybackClient
that are needed from the ref'd commit to fix the issue.
il...@google.com <il...@google.com>
pe...@gmail.com <pe...@gmail.com> #4
The fix for this is in mediarouter:1.2.6
(released 2022-01-26).
pe...@gmail.com <pe...@gmail.com> #6
At current now,there is two ways to do the above。
One:
In the NavHostFragment's Activity, override the onBackPress() method,adn if the current NavDestination is MainFragment then just finish the Activity.
@Override
public void onBackPressed() {
NavDestination navDestination = mNavController.getCurrentDestination();
if (navDestination != null
&& navDestination.getId() == R.id.mainFragment) {
finish();
return;
}
super.onBackPressed();
}
Two:
Set the to MainFragment action in Navigation_graph app:popUpTo="@id/nav_graph" and app:popUpToInclusive="true"
<?xml version="1.0" encoding="utf-8"?>
<navigation
android:id="@+id/nav_graph"
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 "
app:startDestination="@id/splashFragment">
<fragment
android:id="@+id/splashFragment"
android:name="com.ihuman.storydemo.fragment.splash.SplashFragment"
android:label="fragment_splash"
tools:layout="@layout/fragment_splash">
<action
android:id="@+id/action_splashFragment_to_mainFragment"
app:destination="@id/mainFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
<action
android:id="@+id/action_splashFragment_to_guideFragment"
app:destination="@id/guideFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
</fragment>
<fragment
android:id="@+id/guideFragment"
android:name="com.ihuman.storydemo.fragment.guide.GuideFragment"
android:label="GuideFragment"
tools:layout="@layout/fragment_guide">
<action
android:id="@+id/action_guideFragment_to_mainFragment"
app:destination="@id/mainFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
</fragment>
<fragment
android:id="@+id/mainFragment"
android:name="com.ihuman.storydemo.fragment.main.MainFragment"
android:label="fragment_main"
tools:layout="@layout/fragment_main">
</fragment>
</navigation>
Wish for help!
One:
In the NavHostFragment's Activity, override the onBackPress() method,adn if the current NavDestination is MainFragment then just finish the Activity.
@Override
public void onBackPressed() {
NavDestination navDestination = mNavController.getCurrentDestination();
if (navDestination != null
&& navDestination.getId() == R.id.mainFragment) {
finish();
return;
}
super.onBackPressed();
}
Two:
Set the to MainFragment action in Navigation_graph app:popUpTo="@id/nav_graph" and app:popUpToInclusive="true"
<?xml version="1.0" encoding="utf-8"?>
<navigation
android:id="@+id/nav_graph"
xmlns:android="
xmlns:app="
xmlns:tools="
app:startDestination="@id/splashFragment">
<fragment
android:id="@+id/splashFragment"
android:name="com.ihuman.storydemo.fragment.splash.SplashFragment"
android:label="fragment_splash"
tools:layout="@layout/fragment_splash">
<action
android:id="@+id/action_splashFragment_to_mainFragment"
app:destination="@id/mainFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
<action
android:id="@+id/action_splashFragment_to_guideFragment"
app:destination="@id/guideFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
</fragment>
<fragment
android:id="@+id/guideFragment"
android:name="com.ihuman.storydemo.fragment.guide.GuideFragment"
android:label="GuideFragment"
tools:layout="@layout/fragment_guide">
<action
android:id="@+id/action_guideFragment_to_mainFragment"
app:destination="@id/mainFragment"
app:enterAnim="@anim/anim_right_in"
app:exitAnim="@anim/anim_left_out"
app:popEnterAnim="@anim/anim_left_in"
app:popExitAnim="@anim/anim_right_out"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
</fragment>
<fragment
android:id="@+id/mainFragment"
android:name="com.ihuman.storydemo.fragment.main.MainFragment"
android:label="fragment_main"
tools:layout="@layout/fragment_main">
</fragment>
</navigation>
Wish for help!
Description
Version used: 1.0.0-alpha07
The clearTask and launchDocument flags and attributes have been deprecated for a number of releases - they should be removed.