当我的应用程序加载时,如何避免 Android 黑屏?
当我的应用程序加载时,如何避免 Android 中出现黑屏?我已经删除了从 onCreate 到 AsyncTask 的所有内容,但一开始我仍然有黑屏。我的默认(第一个)活动是 Main,如果有一个参数,我会立即加载个人活动而不显示 Main,否则我显示 Main 活动。有人可以建议我解决方案吗? 我尝试使用 http://blog.iangclifton.com /2011/01/01/android-splash-screens-done-right/ 但这没有帮助。
How to avoid black screen in android while my app is loading ? I have removed all things from onCreate to AsyncTask but still I have black screen at the beginning. My default ( first ) activity is Main and if there is one parameter I momentarily load Personal activity withou showing Main, otherwise I show Main activity. Can anyone suggest me solution ?
I tried with http://blog.iangclifton.com/2011/01/01/android-splash-screens-done-right/ but it doesn't help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道。
但是,在您的
activity
内的Manifest
中尝试一下或者
我已经看到了一个关于启动屏幕的很好的解决方案...希望它有用
https://stackoverflow.com/a/8654361/762919
i'm not sure.
but, Try this in
Manifest
inside youractivity
Or
I have seen a good solution about splash screen... hope it useful
https://stackoverflow.com/a/8654361/762919
在 android style.xml 文件的 style 标签中添加以下行。
完整代码:
Add below line in your android style.xml file in style tag .
Complete code :
优化你的代码,尝试减少 onCreate() 中的代码,这是我面临的问题,我通过减少 onCreate() 中的代码解决了它。
祝你好运
Optimize ur code,try to reduce code from onCreate(),this was issue faced by me i solved it by reducing code in onCreate().
Best of Luck
由于您已经清除了 onCreate() 并将初始化任务分配给工作线程,因此在应用程序启动后屏幕仍然保持黑暗一段时间的事实可能是由于图形的复杂性 在您的初始显示中(而不是初始化代码,这可能与模型相关,而不是与视图相关)。
您所说的对您有用的解决方案是使用可见背景作为您的主题。我很高兴您发现这已经足够了,但出于某些目的,更具体的(例如徽标/应用程序名称)启动屏幕(由于使用更简单的图形而显示速度更快)会更理想。
请参阅下面链接的答案,了解如何实现快速显示的启动屏幕的详细说明(带有示例代码):
创建一个真正的启动屏幕
这也讨论了您上面接受的方法。
Since you have cleared out your onCreate() and assigned your initialization tasks to a worker thread, the fact that your screen nonetheless remains dark for a while after your app is launched is probably due to the complexity of the graphics in your initial display (rather than to your initialization code, which is probably model-related, rather than view-related).
The solution that you say worked for you is to use a visible background as your theme. I'm glad that you found that to be adequate, but for some purposes a more specific (e.g., logo / app name) splash screen (which displays quickly because it uses much simpler graphics) would be more desirable.
Please see the answer linked below for a detailed description (with sample code) of how a splash screen that displays quickly can be implemented:
Create a true splash screen
This also discusses the approach that you have accepted above.