有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java泄漏了Windows com。安卓内部的政策恳求

我正在试图解决一个突然出现的日志异常。 我以前从未见过它,但是,我已经5周没有运行过这个应用程序了,所以它可能是任何更新或其他东西的新功能。 这是我的班级代码:

public class SplashScreen extends Activity {

    // Splash screen timer
    private static int SPLASH_TIME_OUT = 1000;
    private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
    private static final String TAG = "SplashPush";

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

        new Handler().postDelayed(new Runnable() {

            /*
             * Showing the splash screen for the selected time
             */
            @Override
            public void run() {
                // Once the timer is over we will start the main activity
                Intent i = new Intent(SplashScreen.this, ClientDriverMainScreen.class);
                startActivity(i);

                // close this activity
                finish();
            }
        }, SPLASH_TIME_OUT);

        if (checkPlayServices()) {
            Intent i = new Intent(this, RegistrationIntentService.class);
            startService(i);
        }
    }

        /**
         * Check the device to make sure it has the Google Play Services APK. If
         * it doesn't, display a dialog that allows users to download the APK from
         * the Google Play Store or enable it in the device's system settings.
         */
    private boolean checkPlayServices() {
        GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (apiAvailability.isUserResolvableError(resultCode)) {
                apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                        .show();
            } else {
                Log.i(TAG, "This device is not supported.");
                finish();
            }
            return false;
        }
        return true;
    }
}

但我一直得到一个例外:

Activity activiteslogic.splash.SplashScreen has leaked window.

任何人都有线索或线索去寻找什么

完整日志:

08-22 12:41:03.609 1849-1849/zooz.ivmobs.com.zooz E/WindowManager: 安卓.view.WindowLeaked: Activity activiteslogic.splash.SplashScreen has leaked window com.安卓.internal.policy.impl.PhoneWindow$DecorView{52860efc V.E..... R......D 0,0-1026,639} that was originally added here
                                                                   at 安卓.view.ViewRootImpl.<init>(ViewRootImpl.java:346)
                                                                   at 安卓.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
                                                                   at 安卓.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
                                                                   at 安卓.app.Dialog.show(Dialog.java:286)
                                                                   at activiteslogic.splash.SplashScreen.checkPlayServices(SplashScreen.java:65)
                                                                   at activiteslogic.splash.SplashScreen.onCreate(SplashScreen.java:48)
                                                                   at 安卓.app.Activity.performCreate(Activity.java:5231)
                                                                   at 安卓.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                   at 安卓.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                   at 安卓.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                   at 安卓.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                   at 安卓.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                   at 安卓.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at 安卓.os.Looper.loop(Looper.java:136)
                                                                   at 安卓.app.ActivityThread.main(ActivityThread.java:5001)
                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
                                                                   at java.lang.reflect.Method.invoke(Method.java:515)
                                                                   at com.安卓.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                   at com.安卓.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                   at dalvik.system.NativeStart.main(Native Method)

共 (2) 个答案

  1. # 1 楼答案

    你可以把你的意图放在checkPlayServices()中,当你用完谷歌的东西后启动它

     private boolean checkPlayServices() {
            GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
            int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
            if (resultCode != ConnectionResult.SUCCESS) {
                if (apiAvailability.isUserResolvableError(resultCode)) {
                    apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                            .show();
                } else {
                    Log.i(TAG, "This device is not supported.");
    
                    // start new activity when you are done here.
                    Intent i = new Intent(SplashScreen.this, ClientDriverMainScreen.class);
                    startActivity(i);
    
                   // close this activity
                    finish();
                }
                return false;
            }
            return true;
        }
    
  2. # 2 楼答案

    用于更改此活动的上下文。这个

        if (checkPlayServices()) {
            Intent i = new Intent(SplashScreen.this, RegistrationIntentService.class);
            startService(i);
        }
    
    
    
    
    private boolean checkPlayServices() {
        GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        int resultCode = apiAvailability.isGooglePlayServicesAvailable(SplashScreen.this);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (apiAvailability.isUserResolvableError(resultCode)) {
                apiAvailability.getErrorDialog(SplashScreen.this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                        .show();
            } else {
                Log.i(TAG, "This device is not supported.");
                finish();
            }
            return false;
        }
        return true;
    }