3

I am using Google Drive core API for file CRUD. All things are working fine but I am unable to get Google Drive account name in onActivityResult() method. My code is as follows:

In onCreate():

String[] accountTypes = new String[]{"com.google"};
                        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                                accountTypes, false, null, null, null, null);
                        startActivityForResult(intent, REQ_AUTH);

In onAcivityResult():

protected void onActivityResult(final int rqst, final int rslt,
                    final Intent data) {
                if ((rqst == REQ_AUTH) && (rslt == Activity.RESULT_OK)) {

                    accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);

                    if (accountName != null) {
                        googleApiClient.init(UploadFileOnGoogleDrive.this, accountName)
                                .connect();
                    }
                }

Here, data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME) always returning null. I also putted condition like data!=null && data.getStringExtras()!=null but the condition never get satisfied. Please help me.

Sandeep Singh
  • 1,117
  • 2
  • 11
  • 29
Amol Suryawanshi
  • 2,108
  • 21
  • 29

0 Answers0