开发者

How to hide my application but not close/finish it

I would like to let user to leave my application by hiding it but not finishing it.

I could call finish() in my main activity, but it takes some time to do that. It's not good for user experience, therefore a better choice might be to hide it. Just I don't know how to achieve it.

Thanks for all the answer.


I am not trying to do something in the background, because I already have a service.

In my application, user might press an button to close my main activity. However, it take a little time to do that. At least after 0.5 sec, then I'll see my application disappear on screen.

However, if I pre开发者_运维百科ss home key. My application is disappear immediately, so it's the effect I need.


You could try to move your activity in the background

moveTaskToBack(true);


If you need your app to continue running in the background, spawn the background code in a Service.

http://developer.android.com/reference/android/app/Service.html


The best advice here is simply to start looking at all of the garbage collection the app has to do and make sure you only keep things (connections, etc) open for as long as absolutely necessary.

Point is to limit the amount of stuff the app has to do to finally shut down.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜