安卓启动画面一开始是白色的?

3
当我启动我的应用程序时,我会先看到一个白屏几秒钟,然后才会出现启动画面。我想知道我的应用程序大小是否会影响它(它是17.7MB)?还是因为我的测试设备旧(HTC Desire HD),太多数据挤了它?这是正常行为吗?或者问题出在我的代码上,下面是一部分清单:
    <activity android:name=".SplashView"
          android:noHistory="true"
          android:screenOrientation="portrait"
          android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" 
        android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation" >
        <intent-filter >
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

启动画面:

public class SplashView extends SherlockActivity {
private final int SPLASH_DISPLAY_LENGHT = 1000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide();
    setContentView(R.layout.splash_view);
    try {
        RefreshRatingsTask urt = new RefreshRatingsTask();
        urt.execute();
    } catch (Exception e) {
        // ignore
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent mainIntent = new Intent(SplashView.this,
                    MainActivity.class);
            SplashView.this.startActivity(mainIntent);
            SplashView.this.finish();
        }

    }, SPLASH_DISPLAY_LENGHT);
}
}

谢谢


我认为这是旧设备和重应用程序的混合。当我在我的摩托罗拉香料手机上打开愤怒的小鸟时,就会出现白屏大约20秒钟。 - Geeky Guy
2个回答

9
Android使用初始Activity的主题来展示一个虚拟的Activity,同时将应用程序加载到内存中。使您的应用程序更小将有助于减少等待时间,并使用主题设置闪屏屏幕的样式将使其不那么明显。Cyril Mottier的这篇博客文章提供了更多详细信息。

0
    RefreshRatingsTask urt = new RefreshRatingsTask();
    urt.execute();

这个异步任务似乎是罪魁祸首。 它的操作可能需要时间,因此闪屏画面不会立即出现。 将其注释掉并再次检查。
此外,在闪屏活动中进行重活负载的做法并不好。 为其创建一个服务并在后台执行。


谢谢您的回复。顺便说一下,RefreshRatingTask继承自AsyncTask,因此它应该不会有问题,因为它在单独的线程中运行。但是即使将其注释掉后,问题仍然存在... - user2224342
谢谢反馈。是的,我知道它是一个异步任务。你在其他设备上测试过吗?模拟器?结果是否相同? - Lazy Ninja
是的..三星S3上也有同样的问题。我想我得想办法提高应用程序的速度并减小它的大小。 - user2224342

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接