1

I have an android app. The used cases are as below

  1. From activity A can navigate to activity B via startActivity() and activity A is still on the 'STACK' (A is not finished).

  2. Activity B is a subclass of google MapActivity

  3. On Press of the BACK button , navigation should be from B to A.

The above use case works fine until I upgraded to Android 4.1.1(works fine from 2.3.3 to 4.0.x).

On my current 4.1.1(Samsung S3), the "BACK' button usually not working. When I press the BACK button, the button light up but no action is performed.

I even override the OnPressBack() method and placed a Toast message as a flag. But looks like the OnPressBack() is not triggered usually. Sometimes it works but most of the time it does not work(go to previous activity A).

And I also found the BACK button issue only happened with the subclass of 'MapActivity'.

Any clue will help. Thanks...

Avi Kumar
  • 4,403
  • 8
  • 36
  • 67
andrewwang1TW
  • 119
  • 3
  • 14

1 Answers1

0

If you're using the new navigation components, you need to make sure the activity that contains your navController overrides the onSupportNavigateUp() function:

override fun onSupportNavigateUp() = findNavController(R.id.nav_host_fragment).navigateUp()
Code on the Rocks
  • 11,488
  • 3
  • 53
  • 61