how to completely get rid of an activity's GUI (avoid a black screen)

http://stackoverflow.com/questions/4551868/how-to-completely-get-rid-of-an-activitys-gui-avoid-a-black-screen

Question:

I'm trying to write a very simple app that will do just one very simple non-GUI action, then display a short message (using toast, on top of what was already on the screen, e.g. home screen), and finish. That's all.

This almost works, but i'm still getting a brief black screen after the app starts, then back to home screen and things work as i intend after that. I thought that not using setContentView on my activity (thus depriving it of a View) would be enough to avoid the black screen, but it still pops up.Please notice that (as suggested in a related question), a service is not the answer to my problem. I just want a GUI-less (except for one toast) app that runs and ends right away.Thanks :)

Answer:

In in your manifest use android:theme="@android:style/Theme.NoDisplay".

Note this assumes you will call finish() before returning from onResume(). If you are going to do more work after that (for example if you will be doing any networking or other such thing that can't be done quickly synchronously), you will probably want to start a service to take care of the work to tell the platform your process should continue running after the activity finishes.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值