Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file 1: Image51315.jpg
- file 2: Image59192.jpg
- ...
- Drive.DriveApi.requestSync(mGoogleApiClient).await();
- Drive.DriveApi.getRootFolder(mGoogleApiClient)
- .listChildren(mGoogleApiClient)
- .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
- @Override
- public void onResult(DriveApi.MetadataBufferResult result) {
- if (!result.getStatus().isSuccess()) {
- Log.v("DKDK", "Request failed");
- return;
- }
- MetadataBuffer metadataBuffer = result.getMetadataBuffer();
- //Log.e("Resultados",""+metadataBuffer);
- Iterator itr = result.getMetadataBuffer().iterator();
- while (itr.hasNext()) {
- Metadata metadata = (Metadata) itr.next();
- mImageName = metadata.getTitle();
- Log.e("GDRIVE", "Title " + metadata.getTitle() + " MimeType " + metadata.getMimeType());
- FileID = metadata.getDriveId();
- Log.e("GDRIVE", "" + FileID);
- }
- if (metadataBuffer.getCount() == 0) {
- Log.e("GDRIVE", "Creando archivo nuevo");
- } else {
- // FileID = metadataBuffer.get(0).getDriveId();
- Log.e("GDRIVE", "Hay Archivos");
- }
- metadataBuffer.release();
- }
- });
- private void storeImage(Bitmap image) {
- File pictureFile = getOutputMediaFile();
- if (pictureFile == null) {
- Log.e("FOTO",
- "Error creating media file, check storage permissions: ");// e.getMessage());
- return;
- }
- try {
- FileOutputStream fos = new FileOutputStream(pictureFile);
- image = Bitmap.createScaledBitmap(image, 500, 500, false);
- image.compress(Bitmap.CompressFormat.PNG, 100, fos);
- fos.close();
- } catch (FileNotFoundException e) {
- Log.d("FOTO", "File not found: " + e.getMessage());
- } catch (IOException e) {
- Log.d("FOTO", "Error accessing file: " + e.getMessage());
- }
- Log.e("FOTO", "PATH>> " + mCurrentPhotoPath);
- }
- /**
- * Create a File for saving an image or video
- */
- private File getOutputMediaFile() {
- // To be safe, you should check that the SDCard is mounted
- // using Environment.getExternalStorageState() before doing this.
- final File mediaStorageDir = new File(Environment.getExternalStorageDirectory()
- + "/Android/data/"
- + getApplicationContext().getPackageName()
- + "/Files");
- // This location works best if you want the created images to be shared
- // between applications and persist after your app has been uninstalled.
- // Create the storage directory if it does not exist
- if (!mediaStorageDir.exists()) {
- if (!mediaStorageDir.mkdirs()) {
- return null;
- }
- }
- Log.e("AFUERAIV", "" + mImageName);
- mCurrentPhotoPath = (mediaStorageDir.getPath() + File.separator + mImageName);
- mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName);
- return mediaFile;
- }
Add Comment
Please, Sign In to add comment