如何避免上启动应用程序黑色屏幕 [英] How to avoid Black Screen on starting an application

查看:109
本文介绍了如何避免上启动应用程序黑色屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始我的应用程序开始,我得到一个黑色的屏幕,停​​留几秒钟,我的主要活动开始之前。如果iPhone与名称默认的图像显示这一瞬间。我不知道如何在Android的做同样的。我试过如下徒劳的:

 <活动机器人:名称=指数
              机器人:标签=@字符串/ APP_NAME
              机器人:screenOrientation =画像
              机器人:主题=@可绘制/ defaultimage>
            <意向滤光器>
              <作用机器人:名称=android.intent.action.MAIN/>
              <类机器人:名称=android.intent.category.LAUNCHER/>
          &所述; /意图滤光器>
        < /活性GT;
 

解决方案

我想你有你的索引活动的onCreate方法沉重的操作。

您应该把沉重的运算线程,并启动画面的图像,当线程完成,加载菜单或任何你需要的。

您可以做一个载入画面为例。这真的很容易与Android:<一href="http://developer.android.com/intl/fr/guide/appendix/faq/commontasks.html#progressbar">http://developer.android.com/intl/fr/guide/appendix/faq/commontasks.html#progressbar或<一href="http://developer.android.com/intl/fr/reference/android/widget/ProgressBar.html">http://developer.android.com/intl/fr/reference/android/widget/ProgressBar.html

When I start my application initially, I get a black screen which stays for a few seconds before my main activity starts. In case of iphone an image with name default is displayed for that split second. I'm not sure how to do the same in Android. I tried as below in vain :

         <activity android:name=".Index"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:theme="@drawable/defaultimage">
            <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>  

解决方案

I guess you have a heavy operation on the onCreate method of your "Index" Activity.

You should put the heavy operations on a thread and make a splash screen with the image, and when the thread is finished, load the menu or whatever you need.

You can make a "loading screen" for example. It's really easy with Android: http://developer.android.com/intl/fr/guide/appendix/faq/commontasks.html#progressbar or http://developer.android.com/intl/fr/reference/android/widget/ProgressBar.html

这篇关于如何避免上启动应用程序黑色屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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