Delay while launching activity from service

后端 未结 2 1435
暖寄归人
暖寄归人 2020-12-10 16:30

I have a broadcast receiver which receives screen off broadcast, and when the screen is turned off, it launches an Activity. I\'ve named this activity LockScreenActivity. I\

相关标签:
2条回答
  • 2020-12-10 16:59

    Please find the solution here

    Using Pending Intent and sending out the request immediately solved the problem for me, hope it helps you too :)

    0 讨论(0)
  • 2020-12-10 17:25

    After much digging, found out the cause of the problem. Apparently it's not a bug, it is a feature which does not allow Services or BroadcastReceivers to launch activities for up to 5 seconds after home button is pressed. No easy way to overcome this.

    More info here: https://code.google.com/p/android/issues/detail?id=4536

    I replaced the activity with a Window added to the window manager of the running service. This does not cause any delay.

    0 讨论(0)
提交回复
热议问题