I need to show a lockscreen after 15 seconds of user inactivity. In my project I use ViewPager
with three pages.
How can I check for inactive user action in all the three pages and all the elements on this pages?
I need to show a lockscreen after 15 seconds of user inactivity. In my project I use ViewPager
with three pages.
How can I check for inactive user action in all the three pages and all the elements on this pages?
You could use a timer that shows a lockscreen after 15 secs of inactivity and zero its timing in the Activity
's onUserInteraction()
method.
You can do this :
WindowManager wm = Context.getSystemService(Context.WINDOW_SERVICE); //Get the context
Window window = getWindow();
window.addFlags(wm.LayoutParams.FLAG_DISMISS_KEYGUARD); //Unlock the screen
DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); //Lock the screen
Note : you may need reference to an activity that can communicate with window.
check this link : link
Use handler for time :
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// write you code
}
}, 15000;//15sec