1

I have 7 different activities and an 8th activity which asks for pass code to continue

Whenever I press home button and access it through the recent apps I want to call the 8th activity to check passcode and then continue to the same activity that I left off

Kevin Kurien
  • 812
  • 6
  • 14

3 Answers3

2

if I come across this situation. I'll create an Activity, and 7 fragments. I only use onResume 1 time.

phuongzzz
  • 85
  • 1
  • 10
TieuNhi
  • 29
  • 4
1

You could use startActivityForResult

in this question you find how to use it. How to manage `startActivityForResult` on Android?

You can start the activity you need (8th), to check the passcode is correct and then return to previous activity.

Bonestack
  • 81
  • 6
1

When your application is resumed through recent apps, it is common to use Android's onResume() method to get things done.

If you, for instance, want the 8th activity to be started, you could do so there through Intents to call the class and check your passcode there. If it's correct, then you can return to activity 7 through Android's finish() method which returns to the last activity on the backstack.

You could take a look at implementing this through the Dialogs API as well, which has a custom implementation for a log in modal.

Panos Gr
  • 667
  • 5
  • 13
  • Even I thought about the same but then I would have to write the same code in all seven activity which is just redundant . I am looking for a better way but if I get no other solution this will be my final option – Kevin Kurien Jun 29 '18 at 08:41