google-drive-android-api

How to upload a folder to Google drive programmatically

匆匆过客 提交于 2019-12-10 23:50:17
问题 I want to upload a folder to Google drive in my android app programmatically. Is there an api which would let me upload / copy an entire folder in my android device to Google drive while preserving the directory structure? All documentation and examples only talk about file uploads but not folder. 回答1: You have 2 different ways to do it. Specifically, 2 different APIs, the REST Api and the GDAA. Basically, the algorithm goes like this: 1/ find root folder 2/ use it as a parent of your first

How to change permission of folder or file created in Google Drive using Google Drive Android API?

余生长醉 提交于 2019-12-10 22:08:21
问题 I'm using Google Drive Android API to store and share files and folders created. When I create a file/folder using Google Drive Android API ,by default created file or folder is private (not shared publicly) . When I share the link of file/folder created to any user, that user needs to send email request for access to owner. So owner have to make file/folder public manually in Google Drive to prevent access requests. Where as for Google Drive iOS API , when a file/folder is created, the file

After disconnecting app Google Drive Android API still returns successful results, but doesn't upload file

人走茶凉 提交于 2019-12-10 14:00:01
问题 I'm using Google Drive Android API (as part of Google Play Services) to upload files to cloud. To connect client I'm using following code (simplified): apiClient = new GoogleApiClient.Builder(context) .addApi(Drive.API) .setAccountName(preferences.getString("GOOGLE_DRIVE_ACCOUNT", null)) .build(); ConnectionResult connectionResult = apiClient.blockingConnect(SERVICES_CONNECTION_TIMEOUT_SEC, TimeUnit.SECONDS); if (!connectionResult.isSuccess()) { throw new ApiConnectionException(); //our own

Google Drive Api v3 and proguard

假如想象 提交于 2019-12-10 13:17:14
问题 After shrinking my release apk with proguard files().list() returns no files (in debug mode it does). I used the quickstart sample for login. There are no error messages. Login seems to be successful. Here is my proguard.cfg: -optimizationpasses 1 #-dontoptimize -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!class/unboxing/enum -dontwarn android.support.v4.** -dontwarn com.google.**

MIME type switched from “image/jpeg” to “image/png”

断了今生、忘了曾经 提交于 2019-12-10 11:53:29
问题 The following 2 code snippets demonstrate the problem I ran into with the NEW Google Drive Android API / Google Play Services 4.2 (libver 15). Or is it a feature I don't know about? All error checking and initialization is removed in order to keep the code simple. 1/ I create a picture of "image/jpeg" MIME type; GoogleApiClient mGAC; byte[] jpgBuffer; DriveFolder fldr; ContentsResult rslt = Drive.DriveApi.newContents(mGAC).await(); Contents cont = rslt.getContents(); cont.getOutputStream()

Upload large files to the Google Drive

前提是你 提交于 2019-12-10 11:10:33
问题 In my app, I'm uploading files to the google drive using GD API . It works fine for small file sizes, but when file size is large (ex: 200MB), it throws java.lang.OutOfMemoryError: exception. I know why it crashes it loads the whole data into the memory, can anyone suggest how can I fix this problem? This is my code: OutputStream outputStream = result.getDriveContents().getOutputStream(); FileInputStream fis; try { fis = new FileInputStream(file.getPath()); ByteArrayOutputStream baos = new

Android Google DriveApi returning different DriveID for same title on different devices

久未见 提交于 2019-12-10 10:09:45
问题 So first of all I know that the DriveID for each file/folder is device specific, BUT the resourceId is constant and that's really what I'm using to test if the items are the same (besides the title of course). Problem I am trying to sync folders in my AppFolder across devices, however, I'm getting different files/folders on each device despite querying via the title before doing anything. So some code: How I set up the api client mGoogleApiClient = new GoogleApiClient.Builder(context

How to use the setResultCallback method?

删除回忆录丶 提交于 2019-12-10 08:02:13
问题 import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import android.app.Activity; import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender.SendIntentException; import android.graphics.Bitmap; import android.os.Bundle; import android.provider.MediaStore; import android.util.Log; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; import com

Google Drive Android API returns success even after removing the app

时光毁灭记忆、已成空白 提交于 2019-12-10 03:05:44
问题 I'm using the new Google Drive Android API. This is the demo code that I've copied from Google's android-samples repo. GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(this); if (signInAccount != null && signInAccount.getGrantedScopes().containsAll(requiredScopes)) { initializeDriveClient(signInAccount); } else { ... } The issue I'm facing is, even if I remove the app from Drive, getLastSignedInAccount() is still returning the account and the operations (such as adding

Google Drive integration using current activity

杀马特。学长 韩版系。学妹 提交于 2019-12-10 01:14:26
问题 Is it possible to integrate with Google Drive without creating ones own activity, instead just using the current activity for the application without polluting it with Google Drive related code? I have a background "service" (not an Android service - just a UI-agnostic class) that is responsible for loading some data from Google Drive. As a service, it has no real business being an activity. However, the samples for Drive integration have an override of onActivityResult to handle the