GoogleAPIClient connection failed

806 views Asked by At

I am trying to connect to GoogleDrive through my application. The Drive gets connected through certain gmail_id's but connection fails for few ids.

Can any guide me what change i need to do? Why the connection vary from id to id?

Code:

@Override
    protected void onResume() {
        super.onResume();
        if (mAccountName == null) {
            return;
        }

        if (mGoogleApiClient == null) {
            mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            //                    .addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
            //                    .setAccountName(mAccountName)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
//          .addApi(Plus.API)
            .build();
        }
        mGoogleApiClient.connect();
    }

@Override
    public void onConnectionFailed(ConnectionResult result) {
        super.connectionFailed(result);
        ++count;
        if(!result.hasResolution()){
            System.out.println("result code = " + result.toString());
            if(dialog != null){
                dialog.dismiss();
            }
            String message = "";
            if(!SUICommon.isInternetOn(BackupDbData.this)){
                message = "Check your internet connection and try again.";
            }
            else{
                message = "Unable to connect to drive.";
            }
            SingleButtonDialog singleButtonDialog = new SingleButtonDialog(BackupDbData.this, message,true);
            singleButtonDialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_button);
            singleButtonDialog.setCancelable(false);
            singleButtonDialog.show();
        }
    }
0

There are 0 answers