0

Good evening!

I'm writing an android version of my application and I have little problems to understand the fingerprint logic. The code integration of fingerprint is not the problem - my problem is to understand the difference to iOS.

On iOS I use Touch-ID by every app opening from user via applicationWillEnterForeground. For example the user press the application icon he have to authenticate with his finger. If he left the app and click the app icon again he have to authenticate also again.

I want to add this behaviour to my android app. I've looked at the android activity lifecycle ( https://www.javatpoint.com/images/androidimages/Android-Activity-Lifecycle.png ) and didn't find a good solution. I miss the similar application delegate-method applicationWillEnterForeground from iOS. So I looked for a solution to get a similar method in android:

  1. https://stackoverflow.com/a/12617254
  2. https://stackoverflow.com/a/13809300

Both solutions doesn't work for me.

Link 1 is the idea to sum up all onResume() methods of all activitys in a superclass. But this solution show the user the authentication dialog also "inside" the app - not only when the app is opening from user.

Link 2 is the idea to get a own application-class. The problem is that this application-class is not called when the user press the "back" / "home" button and reopen the app. Also in this case should be the authentication dialog shown.

Thanks for all answers!

  • 1
    Did you not find `Application.ActivityLifecycleCallbacks`: https://stackoverflow.com/q/10606408/295004 – Morrison Chang Aug 28 '17 at 00:13
  • 1
    try to set the authentication interface as th launch activity and just kill the app whenever the user presses the home button or exists the app (whether by backbutton or any other mean) , that way he will have to start from the launcher activity (which is your authentication UI) all over again – Thorvald Aug 28 '17 at 02:45
  • @Morrison Chang Thank you very much for this! It is really helpful for my project - but is not the solution for my problem. For example the onResume() method is fired also inside of the app (activity change inside the app). Do you have a solution with this ActivityLifecycleCallbacks? –  Aug 28 '17 at 17:49
  • @Thorvald Olavsen V. Perfect answer for my problem! That's a really good solution - but with one problem: How can I register, when a user close the app? For example override all onStop() methods is useless because this methods are also fired on activity change inside the app. Any solution? –  Aug 28 '17 at 17:54

0 Answers0