Android的开机画面一开始是白色的



当我启动我的应用程序时,我看到几秒钟的白色屏幕,然后出现启动屏幕

我想知道我的应用程序的大小是否会影响它(它是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);
}
}

谢谢

Android使用你的初始活动的主题来显示一个虚拟活动,同时它将你的应用程序加载到内存

让你的应用更小将有助于减少等待的长度,使用主题来设置启动屏幕的风格将使它不那么明显。

Cyril Mottier的这篇博文有更多的细节。

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

这个asynctask似乎是罪魁祸首。它的操作可能需要时间,因此启动屏幕不会立即出现。注释出来,然后再检查。
此外,在飞溅活动上做重的东西不是一个好的做法。为它创建一个服务并在后台执行

最新更新