I'm developing an application which must start activity when screen of device turns off. I use the BroadcastReceiver with intent filter, and in my receiver I call:
startActivity(new Intent(MyService.this, FullscreenActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS));
The problem is onCreate of my FullscreenActivity begins after 5 seconds after startActivity method call! 5 seconds, Carl! But it happens not every time. For example, if I turn screen off from the desctop, it works immediately. But if some fullscreen application is running, pushing the home button and then pushing the power button makes the 5 seconds delay.
09-13 11:55:32.658 28608-28608/com.incodemobile.incodeandroid.mylocker D/333﹕ Screen off
09-13 11:55:32.658 28608-28608/com.incodemobile.incodeandroid.mylocker D/333﹕ activity started from receiver BEGIN
09-13 11:55:32.698 28608-28608/com.incodemobile.incodeandroid.mylocker D/333﹕ activity started from receiver END
09-13 11:55:37.022 28608-28608/com.incodemobile.incodeandroid.mylocker D/333﹕ oncreate activity start
09-13 11:55:37.673 28608-28608/com.incodemobile.incodeandroid.mylocker D/333﹕ oncreate activity end
Is it possible to reduce this time?