简体   繁体   中英

Android is closing the application from the front while waiting but the process is still alive in the background

I have an app that uses google plus registration, my issue is:

After calling mGoogleApiClient.connect(); and then I have nothing to do except wait for response from gPlus to either fail onConnectionFailed or onConnected .

But while waiting for it strange thing happen my mobile screen gets alittle dimmer like it happens when a dialog has to come up but nothing comes up and application is closed after 1,2 seconds.

However the process is still running because when either onConnectionFailed or onConnected are hit (breakpoints) i can catch them in debugger and move along the statement but there the application (view) is closed over mobile.

Can someone please explain why is this happening and how to resolve this issue?

private void activateGooglePlusLogin() {
        SignInButton googlePlusSignInButton = (SignInButton) findViewById(R.id.googlePlusSignInButton);
        googlePlusSignInButton.setSize(SignInButton.SIZE_WIDE);
        googlePlusSignInButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                try {
                    eGooglePlus googleApiObj = new eGooglePlus(Splash.this);
                    googleApiObj.connectGoogleApi();

                    TextView pleaseWait = (TextView) findViewById(R.id.pleaseWait);
                    pleaseWait.setText("Please wait while we register your account...");
                    //waitForNSeconds(10000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    }

    public void connectGoogleApi() {
        mGoogleApiClient = new GoogleApiClient.Builder(mainAppContext).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();
        mGoogleApiClient.connect();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM