簡體   English   中英

Android正在等待時從前端關閉應用程序,但該過程仍在后台運行

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

我有一個使用google plus注冊的應用,我的問題是:

調用mGoogleApiClient.connect(); 然后除了等待gPlus的響應使onConnectionFailedonConnected失敗之外,我什么都不做。

但是,在等待它的同時,奇怪的事情發生了,我的手機屏幕變暗了,就像在必須彈出對話框但沒有出現任何東西並且在1,2秒后關閉應用程序時一樣。

但是該過程仍在運行,因為當onConnectionFailedonConnected被擊中(斷點)時,我可以在調試器中捕獲它們並沿語句移動,但該應用程序(視圖)已通過移動設備關閉。

有人可以解釋為什么會發生這種情況以及如何解決此問題嗎?

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();
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM