如何彻底摆脱一个活动的图形用户界面(避免黑屏) [英] how to completely get rid of an activity's GUI (avoid a black screen)

查看:125
本文介绍了如何彻底摆脱一个活动的图形用户界面(避免黑屏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个非常简单的应用程序,将做的只是一个非常简单的非GUI操作,然后显示一个短消息(用面包,对什么是已经在屏幕上,如主屏幕顶部),以及完。这一切。

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.

这几乎是工作,但我仍然得到一个短暂的黑屏应用程序启动后,再回到主屏幕和工作的事情,我以后打算。我认为,不使用的setContentView在我的活动(从而剥夺了观看)将足以避免黑屏,但它仍然弹出。 请注意,(如在一个相关的问题提出的建议),服务不回答我的问题。我只想要一个图形界面的(除了一个烤面包片)的应用程序运行,结束的时候了。 感谢:)

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 :)

推荐答案

<活性GT; 在清单中使用

android:theme="@android:style/Theme.NoDisplay"

请注意这是假定你会调用完成() onResume返回前()。如果你打算以后做更多的工作(例如,如果你会做任何网络或其他类似的东西,不能迅速同步完成的),你可能会想启动一个服务,把工作的关心,告诉该平台的进程应该继续运行该活动结束后。

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.

这篇关于如何彻底摆脱一个活动的图形用户界面(避免黑屏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆