Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Application crash when I try to open text file #2

Open
dfistric opened this issue Aug 4, 2015 · 1 comment
Open

Application crash when I try to open text file #2

dfistric opened this issue Aug 4, 2015 · 1 comment

Comments

@dfistric
Copy link

dfistric commented Aug 4, 2015

Hi,

I imported this sample to Android studio, but I have one small problem and don't know whats causing it.
Everything works except opening text file inside editor.

I traced the problem to:

    private void get() {
        Log.d(TAG, "Retrieving...");
        DriveFile file = Drive.DriveApi.getFile(mGoogleApiClient, mCurrentDriveId);
        final PendingResult<MetadataResult>
                metadataResult = file.getMetadata(mGoogleApiClient);
        final PendingResult<DriveContentsResult>
                contentsResult = file.open(mGoogleApiClient,
                DriveFile.MODE_READ_ONLY | DriveFile.MODE_WRITE_ONLY, null);
    }

to be exact this line:

            DriveFile file = Drive.DriveApi.getFile(mGoogleApiClient, mCurrentDriveId);

it produced following error:

08-04 10:54:11.644  30118-30118/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3, result=-1, data=Intent { act=android.intent.action.PICK (has extras) }} to activity {com.google.android.gms.drive.sample.quickeditor/com.google.android.gms.drive.sample.quickeditor.HomeActivity}: java.lang.IllegalStateException: Client must be connected
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3408)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3451)
            at android.app.ActivityThread.access$1200(ActivityThread.java:154)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5306)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: Client must be connected
            at com.google.android.gms.drive.internal.zzq.getFile(Unknown Source)
            at com.google.android.gms.drive.sample.quickeditor.HomeActivity.get(HomeActivity.java:224)
            at com.google.android.gms.drive.sample.quickeditor.HomeActivity.onActivityResult(HomeActivity.java:186)
            at android.app.Activity.dispatchActivityResult(Activity.java:5444)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3404)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3451)
            at android.app.ActivityThread.access$1200(ActivityThread.java:154)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5306)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)

Client must be connected. Don't understand because mGoogleApiClient and mCurrentDriveId have their values and connection to the drive works because I can create files, can get list of files and so on.

I also tried few different samples like Android quickstart and it also fails on ReadContents.

Don't know what I'm missing here. On developer console I added credentials to accept this application (w/o it can't connect), Google Drive API is enabled, is there maybe something else.

Sorry if I'm missing something obvious.
Best regards,
Dubravko

@kroikie kroikie self-assigned this Dec 21, 2015
@androidvk
Copy link

DriveFile driveFile=mSelectedFileDriveId.asDriveFile();
I used this method to solve problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants