Reason for 5 sec delay to show an activity on pressing the home button?

时光怂恿深爱的人放手 提交于 2019-11-28 05:41:57

问题


I am facing delay of 5 sec to show an Activity after pressing the HOME key. I had gone through some post and found that after pressing the HOME button, android prevents services and broadcast-receivers from calling startActivity for 5 seconds.

Q1. Can anyone please let me know the reason to happening this delay ?

Q2. When I modified the ActivityManagerService::checkAppSwitchAllowedLocked() to always return true, it avoids checking lock and hence Activity gets shown without any delay. Would it be a good solution to avoid delay or it may cause any wrong effect in other ways ?


回答1:


I know, it's probably too late (half year passed). However, here is the answer

  • You won't be able to get this permission on not rooted phone, unless your application is signed with the same keys as system. Android has some permissions like that.

  • Also, you may be interested to check this question. Starting an activity from a service after HOME button pressed without the 5 seconds delay



来源:https://stackoverflow.com/questions/8163399/reason-for-5-sec-delay-to-show-an-activity-on-pressing-the-home-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!