-4

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?

  • possible duplicate of [Starting an activity from a service after HOME button pressed without the 5 seconds delay](http://stackoverflow.com/questions/5600084/starting-an-activity-from-a-service-after-home-button-pressed-without-the-5-seco) – Kane O'Riley Sep 13 '15 at 08:34

1 Answers1

0

There is a hardcoded delay of 5 seconds after pressing the home button, to ensure a user always has a way to escape from an application and get back to the home screen.

You can read more at this issue post, it is an undocumented safety mechanism that is not likely to ever be changed, and cannot be worked around by third party applications.

Kane O'Riley
  • 2,482
  • 2
  • 18
  • 27