How To Get Images From Google Drive Into Android Application?
i have code to download the image private class DownloadImage extends AsyncTask { @Override protected void onPreExecute()
Solution 1:
Assuming you have a DriveId from when you inserted the image, you can then retrieve the file using Drive.DriveApi.getFile() - this returns you a DriveFile.
Once you have a DriveFile, you can get an InputStream to the contents of the file as a Bitmap using open() and code such as
file.open(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null)
.setResultCallback(
newResultCallback<DriveApi.DriveContentsResult>() {
@OverridepublicvoidonResult(DriveApi.DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
// Handle an error
}
DriveContentsdriveContents= result.getDriveContents();
InputStreamis= driveContents.getInputStream();
Bitmapbitmap= BitmapFactory.decodeStream(is);
// Do something with the bitmap// Don't forget to close the InputStream
is.close();
});
Post a Comment for "How To Get Images From Google Drive Into Android Application?"