question

sam avatar image
sam Deactivated asked sam Deactivated edited

Lockscreen doesn't trigger onPause, onResume lifecycle

When user locks the screen on Clover and comes back, we need to go to our homepage. The issue with that lock screen is that it doesn't interrupt/stop/pause the current activity so we don't have the onResume call when back from that screen. Also, the screen doesn't turn off so checking for turn on/off events doesn't help.
lockscreenlifecycle
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

sam avatar image
sam Deactivated answered sam Deactivated edited
Lockscreen is a window and not an activity so it will not trigger the lifecycle. You can listen to the lockscreen using a listener for `ACTION_USER_PRESENT` or if you only need to act when the employee changes, you can use EmployeeIntent.ACTION_ACTIVITY_EMPLOYEE_CHANGED


public class EmployeeChangedReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
if(EmployeeIntent.ACTION_ACTIVE_EMPLOYEE_CHANGED.equals(intent.getAction()) && intent.getStringExtra(Intents.EXTRA_EMPLOYEE_ID) != null) {
context.startService(new Intent(context, StorePINService.class));
}
}
}
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community