0

I'm developing an app that requires certain level of security. I need to have a feature when you press the home button and later enter in the app again, the app requires a password to continue where you've been staying before pushing the home button.

I already tried to do this, but when you call a new activity, the password screen is showed and I only need it when the home button is pressed:

@Override
public void onStop(){
    super.onStop();
    if (!isFinishing()) {
        Intent i = new Intent(this, Register.class);
        startActivity(i);
    }
}

The normal flow is this:

Main->2nd Activity

but if I use the code that I showed, this is the flow:

Main->2nd Activity->Password Activity

It also works for home button but no for normal flow.

I already tried this and it works perfectly, but I don't want to add a new permission.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • HOME is nothing magical. There are plenty of ways for a user to leave an app that do not involve the HOME button, such as using the recent-tasks list to switch to another app, accepting an incoming phone call, and responding to a `Notification`. You need to handle those scenarios as well, not just HOME, if this truly is "an app that requires certain level of security". Most apps of this nature track activity within the app and force re-authentication after a period of inactivity. – CommonsWare May 21 '14 at 19:44
  • I know and that's a good point, but if I manage how to do this, then I can implement all those scenarios. I've done that "timer" function, because it's a necessary function in the app. – Sebastian Ziegler May 21 '14 at 19:46
  • Security is not merely a matter of locking things down, but locking things down sensibly. Users are going to simply not use your app, if they feel that your forced re-login policy is too harsh. Under your plan, if the user spends 10 seconds outside of the app to respond to a text message, they have to log in again, even if they had logged in just a minute ago. Again, most apps of this nature track activity within the app and force re-authentication after a period of inactivity. – CommonsWare May 21 '14 at 19:52
  • That's a good feature to develop, thanks! – Sebastian Ziegler May 21 '14 at 19:57

0 Answers0