google-drive-android-api

Android Drive GooglePlayServicesUtil﹕ The specified account could not be signed in

青春壹個敷衍的年華 提交于 2019-12-07 18:12:32
问题 I need to use the drive api to create a file with some content from my app, so I followed the "Getting Started" section from Drive api web page. So I enabled the api on my developer´s console, created an OAuth client id as it says. (Can I use the api if I haven´t paid the 2$5 yet?) On my settings activity on the onCreate method I'm doing: googleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addScope(Drive.SCOPE_FILE) .addConnectionCallbacks(this)

Check if folder exists, and create it if not

a 夏天 提交于 2019-12-07 16:05:42
I notice that there is not a conclusive answer to this on SO, so I am looking for a canonical answer to the question " How to check if a folder exists, and create it if it does not, using the Google Drive Android API? ". Ideally showing examples of both the asynchronous approach using ResultCallback , and the synchronous approach using .await() . P.S. I am aware of this question with the same title , but the accepted answer is focussing on the known bug of lag on isTrashed() , and is not clear about at which point in the code you actually know the folder exists. Other answers seem out of date.

Google Drive Android not returning latest version of the file

与世无争的帅哥 提交于 2019-12-07 13:08:50
问题 I'm using Drive Android API to sync a file between devices and to hold the latest version on Drive. Since some time ago it started behaving really strange. To see that a file exists and get it's latest version, I do a Query search by that file name and sorting by modified date descending. It returns the correct datetime when the file was updated: final SortOrder sortOrder = new SortOrder.Builder() .addSortDescending(SortableField.MODIFIED_DATE) .build(); final Query query = new Query.Builder(

Upload text file to Google Drive using Android

随声附和 提交于 2019-12-07 06:59:55
问题 Edited: I have set my text into a string like so: String text = ("Hello!"); I want to turn this into a plain text file and then upload to a Google Drive Folder. I have tried on the code below, but it is not complete so I cannot say what errors appear. I am using the Google Drive "Quick-start" Demo, and trying to tailor it for what I need. Link: https://github.com/googledrive/android-quickstart DriverClass: public class UploadDrive extends Activity implements ConnectionCallbacks

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

依然范特西╮ 提交于 2019-12-07 03:45:30
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().write(jpgBuffer); MetadataChangeSet meta = new MetadataChangeSet.Builder() .setTitle("foo.jpg")

Google Drive Rest API on Android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 14:03:49
问题 I'm developing an app for a company and I need to integrate it with Google Drive. I can't use the native API because the company has files not created by the application that needs to be handled, I need the full drive scope, so the REST API is what I must use. Here's the problem, the tutorials are not basic enough for me to get started since I only have a very basic understanding of JSON and REST. The tutorial: https://developers.google.com/drive/web/integrate-create As I understand it I need

Upload large files to the Google Drive

陌路散爱 提交于 2019-12-06 05:36:16
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 ByteArrayOutputStream(); byte[] buf = new byte[8192]; int n; while (-1 != (n = fis.read(buf))) baos.write

Plans for drive.appdata scope in android google drive API

巧了我就是萌 提交于 2019-12-06 03:36:16
问题 I want to use files in the special application data folder in new android application im developing (aka drive.appdata scope). You guys at google did an excelent job in the new Google Drive Android API which is bundled with the Google Play Services 4.2. But I found out that its not possible to use the appdata folder in the Android API, because there is only the scope drive.file. Now I have to use the generic java/web api in android for this. There are plans to implement the drive.appdata

Google Drive API - get list of files including folders

荒凉一梦 提交于 2019-12-05 22:35:17
I need to list all images in a users drive cloud. I use https://www.googleapis.com/drive/v2/files with the correct filter to query all images. I need to group the result in my app in folders. I know a file can have multiple parents, that's fine. I would like to avoid making and calls (for every single file a single call) to get a files folder via https://developers.google.com/drive/v2/reference/files/get using the parent id from the first call. Is there a network friendly way to get all files inclusive there folders? EDIT A simple solution would be to get all folders with ids in one query and

Android Drive GooglePlayServicesUtil﹕ The specified account could not be signed in

这一生的挚爱 提交于 2019-12-05 21:44:44
I need to use the drive api to create a file with some content from my app, so I followed the "Getting Started" section from Drive api web page. So I enabled the api on my developer´s console, created an OAuth client id as it says. (Can I use the api if I haven´t paid the 2$5 yet?) On my settings activity on the onCreate method I'm doing: googleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addScope(Drive.SCOPE_FILE) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); I'm implementing the methods: @Override protected void onStop(){ getGoogleApiClient