0

In my android application have button called Upload whenever i click the button it needs to redirect to Google Drive, from that i have to pick a file & need read the file (file may be csv),

is there anyway to do?? I have tried below code but it shows Client must connected error

GoogleApiClient mGoogleApiClient;

            mGoogleApiClient = new GoogleApiClient.Builder(this)
                    .addApi(Drive.API).addScope(Drive.SCOPE_FILE)
                    .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this).build();

            mGoogleApiClient.connect();

            // Launch user interface and allow user to select file
            IntentSender i = Drive.DriveApi.newOpenFileActivityBuilder()
                    .setMimeType(new String[] { "text/plain" })
                    .build(mGoogleApiClient);
            try {
                startIntentSenderForResult(i, 100, null, 0, 0, 0);
            } catch (SendIntentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

Thanks in advance

Evan Haas
  • 2,524
  • 2
  • 22
  • 34
Madhu
  • 1,780
  • 23
  • 47
  • http://stackoverflow.com/questions/12164024/android-open-and-save-files-to-from-google-drive-sdk – duggu Mar 13 '15 at 05:47

1 Answers1

-1

ACTION_PICK will do the trick.

For example if you were to pick contacts,

Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);

would list your contacts from Drive,Phone Book etc.

Arun Shankar
  • 2,295
  • 16
  • 20