0

在显示背景时,我想运行一些操作(不使用线程)。

在我的活动中,onCreate()我有setContentView(R.layout.splash);

当应用程序触发时onStart(),布局尚未加载。为什么?

更新:LogCat 给我“活动已泄漏窗口”

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView android:src="@drawable/splash"
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ffffff" />
</LinearLayout>

创建

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

}

开始

@Override
protected void onStart() {
    super.onStart();


    if (CBConstants.ASSETS_MANAGER){

        String progressMsg = this.getResources().getString(R.string.progress_dialog_assets_upgrading_message);
        ProgressDialog progressDialog = ProgressDialog.show(this, null, progressMsg);

        progressDialog.show();

        try {

                            [...]

        } catch(Exception e) {
            Log.d("appcheck", ""+e);
            Intent intent = new Intent(SplashScreen.this, CBWebViewActivity.class);
            startActivity(intent);
        }


    }


    else {
        Thread noAssetManager = new Thread() {
        public void run() {
            try {

                while (splashActive && ms < splashTime) {
                    if(!paused)
                        ms=ms+100;
                    sleep(100);
                }

            } catch(Exception e) {
                if (LOG) Log.d("appcheck", ""+e);
            }
            finally {   
                Intent intent = new Intent(SplashScreen.this, CBWebViewActivity.class);
                startActivity(intent);
            }
        }
        };
        noAssetManager.start();
    }

}
4

0 回答 0