When i unlock my device to see my application, the process in onResume()
is launched. How do I cancel the events of unlock, to avoid onResume()
from processing?
Asked
Active
Viewed 533 times
0

Thommy
- 5,070
- 2
- 28
- 51

user1482868
- 31
- 2
- 5
-
This is the expected behaviour. Why would you want to change this? – Raghav Sood Jan 16 '13 at 10:21
-
I guess you can set the timer for auto lock in settings, if I have understood your question properly. – Skynet Jan 16 '13 at 10:22
-
see this: http://stackoverflow.com/questions/4701928/disable-lock-screen – Shreyash Mahajan Jan 16 '13 at 10:24
2 Answers
1
OnResume
is always called when your Activity was in background (e.g. other App, Lockscreen, Homescreen... is shown).
Look at the Activity Life Cycle to check if you can move your code from onResume()
maybe to onStart()
to fix your issue.

Thommy
- 5,070
- 2
- 28
- 51
0
To prevent unlock your device use below flag in your activity.
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
Code
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Note :
As stated on the Activity lifecycle docs, onCreate and onResume will always both be called the first time an Activity is started. When going back to Activity, at least onResume will be called

Chirag
- 56,621
- 29
- 151
- 198