title: Download Image from google drive Android API?
body: <p>I successfully integrated google drive in my android app. But could not download selected image file. 
  Here is my code. There is a problem Result call back method is never execute. Kindly help me. And also I used <strong>data.getData()</strong> method in <strong>onActivity</strong> result this method only <strong>return null</strong>. How I can find URI of image?  </p>
  
  <pre><code>package com.example.syedfurqan.dropboxintegration;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.IntentSender;
  import android.content.IntentSender.SendIntentException;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.net.Uri;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  import com.dropbox.chooser.android.DbxChooser;
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.GoogleApiAvailability;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.common.api.PendingResult;
  import com.google.android.gms.common.api.ResultCallback;
  import com.google.android.gms.drive.Drive;
  import com.google.android.gms.drive.DriveApi;
  import com.google.android.gms.drive.DriveContents;
  import com.google.android.gms.drive.DriveFile;
  import com.google.android.gms.drive.DriveId;
  import com.google.android.gms.drive.DriveResource;
  import com.google.android.gms.drive.Metadata;
  import com.google.android.gms.drive.OpenFileActivityBuilder;
  
  import java.io.InputStream;
  
  
  
  public class BaseDemoActivity extends Activity implements
          GoogleApiClient.ConnectionCallbacks,
          GoogleApiClient.OnConnectionFailedListener {
  
      private static final String TAG = "BaseDriveActivity";
  
      protected static final int REQUEST_CODE_RESOLUTION = 1;
  
      private static final int REQ_CODE_OPEN = 2;
  
  
      private GoogleApiClient mGoogleApiClient;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
         // setContentView(R.layout.activity_base_demo);
          if (mGoogleApiClient == null) {
              mGoogleApiClient = new GoogleApiClient.Builder(this)
                      .addApi(Drive.API)
                      .addScope(Drive.SCOPE_FILE)
                      .addScope(Drive.SCOPE_APPFOLDER) 
                      .addConnectionCallbacks(this)
                      .addOnConnectionFailedListener(this)
                      .build();
          }
          mGoogleApiClient.connect();
      }
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode,
                                      Intent data) {
          switch (requestCode) {
              case REQ_CODE_OPEN:
                  if (resultCode == RESULT_OK) {
                      DriveId mFileId = (DriveId) data
                              .getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);
                      DriveFile selectedFile = mFileId.asDriveFile();
  
  
                      selectedFile.open(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null)
                              .setResultCallback(idCallback);
  
                  } else {
                      finish();
                  }
                  break;
              default:
                  super.onActivityResult(requestCode, resultCode, data);
          }
      }
  
      @Override
      protected void onPause() {
          if (mGoogleApiClient != null) {
              mGoogleApiClient.disconnect();
          }
          super.onPause();
      }
  
  
  //Picker
      @Override
      public void onConnected(Bundle connectionHint) {
          Log.i(TAG, "GoogleApiClient connected");
          // Launch user interface and allow user to select file
          try {
              IntentSender i = Drive.DriveApi
                      .newOpenFileActivityBuilder()
                      .setMimeType(new String[]{"image/png", "image/jpeg"})
                      .build(mGoogleApiClient);
              startIntentSenderForResult(i, REQ_CODE_OPEN, null, 0, 0, 0);
          } catch (Exception e) {
          }
      }
  
      final private ResultCallback&lt;DriveApi.DriveContentsResult&gt; idCallback = new ResultCallback&lt;DriveApi.DriveContentsResult&gt;() {
          @Override
          public void onResult(DriveApi.DriveContentsResult result) {
              if (!result.getStatus().isSuccess()) {
                  // Handle an error
              }
              DriveContents driveContents = result.getDriveContents();
              InputStream is = driveContents.getInputStream();
              Bitmap bitmap = BitmapFactory.decodeStream(is);
              Values.setBitmap(bitmap);
  
          }
      };
  
  
  
      @Override
      public void onConnectionSuspended(int cause) {
          Log.i(TAG, "GoogleApiClient connection suspended");
      }
  
  
      @Override
      public void onConnectionFailed(ConnectionResult result) {
          Log.i(TAG, "GoogleApiClient connection failed: " + result.toString());
          if (!result.hasResolution()) {
              // show the localized error dialog.
              GoogleApiAvailability.getInstance().getErrorDialog(this, result.getErrorCode(), 0).show();
              return;
          }
          try {
              result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
          } catch (SendIntentException e) {
              Log.e(TAG, "Exception while starting resolution activity", e);
          }
      }
  
  
      /**
       * Shows a toast message.
       */
  
      public void showMessage(String message) {
          Toast.makeText(this, message, Toast.LENGTH_LONG).show();
      }
  
  
      /**
       * Getter for the {@code GoogleApiClient}.
       */
  
      public GoogleApiClient getGoogleApiClient() {
          return mGoogleApiClient;
      }
  
  
  }
  </code></pre>