i have a question if there is decent way to handle this situation:
i would like my app to launch passcode activity as soon as application is launched for very first time or then user resumes it from background (for example user clicks home button and moves application into background and then launches it again).
I know i can do this using special permissions and granting access to system tasks, but i don't want to do this way. Also some of you will suggest to use onPause, onResume and onStop - making a boolean variable and change it state from true to false. But this only work when you have one activity - as soon as you move from activity to activity you have to add onActivityResult or something to handle boolean variable.
so maybe you can suggest something more?
UPDATED:
this is sample code from my app main activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {
requestPinCode();
}
/* .. */
}
private void requestPinCode() {
boolean pinStart = false;
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
pinStart = appPrefs.getBoolean("switch_pincode", false);
if (pinStart) {
Intent intent = new Intent(this, PinCodeActivity.class);
startActivity(intent);
}
}
if pinStart is true - it means lock is activated and user must enter passcode on app start. But if you just click home button and start app again no passcode is asked. How to handle this? i want to launch passcode activity as soon as user enters app, but as he navigates inside app - no passcode. Also i want to have this in every activity, not only in main.