android.view.WindowLeaked:Activity

时间:2017-08-06 22:45:29

标签: java android android-intent

我试图制作启动画面,代码显示没有错误,成功构建,但是当它开始时,它会在应用程序中显示此消息

enter image description here

当我检查android监视器上的日志时,它会显示这些消息

08-07 05:41:23.709 16344-16344/com.android.andika.soundsmart E/WindowManager: android.view.WindowLeaked: Activity com.android.andika.soundsmart.SplashS has leaked window DecorView@e044f4c[] that was originally added here
                                                                                  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:418)
                                                                                  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
                                                                                  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
                                                                                  at android.app.Dialog.show(Dialog.java:329)
                                                                                  at android.app.AlertDialog$Builder.show(AlertDialog.java:1112)
                                                                                  at android.app.Activity.performStart(Activity.java:6723)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2662)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
                                                                                  at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:154)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:6236)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

这是我的splashscreen类的代码

public class SplashS extends AppCompatActivity {
    ProgressBar progressBar;
    int status = 0;
    int proses = 0;
    Handler handle = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_s);
        getSupportActionBar().setTitle("SPLASHSREEN");
        ActionBar ab = getSupportActionBar();
        ab.hide();

        progressBar = (ProgressBar) findViewById(R.id.tunggu);
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(status<100){
                    status = loading();
                    handle.post(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setProgress(status);

                        }
                    });
                }
                handle.post(new Runnable() {
                    @Override
                    public void run() {
                        Intent pindah = new Intent(SplashS.this,MenuS.class);
                        startActivity(pindah);
                        finish();
                    }
                });
            }

            private int loading() {
                try{
                    Thread.sleep(45);
                }
                catch(InterruptedException ie){
                    ie.printStackTrace();
                }
                return ++proses;
            }
        }).start();
    }

}

我通过Android N 7.1操作系统的Android手机调试应用程序。

我会感谢任何答案,建议或回应。谢谢:))

1 个答案:

答案 0 :(得分:2)

我认为该错误与显示活动被取消的对话框有关,但是您的代码没有显示任何对话框,因此请检查您是否使用可以执行此操作的第三方库