I'm trying to implement Google Drive to my Android app and I cannot even connect to Api client. And I don't know why:
onConnectionFailed()
I'm calling connectionResult.startResolutionForResult()
if connectionResult.hasResolution()
onActivityResult
for matching requestCode
I'm receiving resultCode == 0
(RESULT_CANCELLED) even when i select my accountDo you have any idea why? I also tried to add:
<meta-data
android:name="com.google.android.apps.drive.APP_ID"
android:value="----"/>
into Manifest which is not mentioned on documentation page but on some SO posts.
Thanks for help
Edit:
I have also tried to use enableAutoManage
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
instead of manualy configuring connection and connectionFailed callbacks:
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
It returns me error code 13 in onConnectionFailed
method. Based on documentation it seems, that this returns when:
OnConnectionFailedListener passed to enableAutoManage(FragmentActivity, GoogleApiClient.OnConnectionFailedListener) when the user choses not to complete a provided resolution. For example by canceling a dialog.
But i didn't cancelled it.
I'm testing it on Nexus 5x - Android N
I found where the problem was while reading something about wallet api
I've just needed to create OAuth client ID not API key
Now it works!