开发者

activity in background

Is there a way to 'preload' a user interfaces but to not display it until I am ready?

I have a service which has a receiver to listen for action_screen_on to occu开发者_JAVA技巧r. When that occurs, I would like to load an activity. However, as it is now, it takes about 1 second to load. I would like to preload the layout in advance so that when the screen is turned on the layout loads as soon as possible.


you just check the flags that you pass to the the Intent which is responsible for running this activity, make sure that you pass (Intent.FLAG_ACTIVITY_SINGLE_TOP), this will make sure that the activity manager will not create new instance of that activity if that one is already there in the activity stack but not in front, this will avoid calling (onCreate) every time you receive this broadcast, and will call (onResume) on the already running activity.

but the 1 sec delay will appear for the first time you lunch that activity only; to solve this problem you just run the profiler and check why is taking this much time, and don't forget; the emulator in general is slow.


I would first suggest just optimizing the display of your activity. Run the profiler on it. 1 second is a long time; there is probably a lot of stuff you can do to reduce that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜