title: Sharing image using intent with Glide library- Image is null always
body: <p>I have a custom listview which is working good, now i want to share the image and text from the list. I have found a step how to do it from SO but image is always null when i click on Share button. </p>
  
  <p>The imageview loading images using Glide. </p>
  
  <pre><code>if (!Patterns.WEB_URL.matcher(Limage).matches()) {
  viewholder.iview.setVisibility(View.GONE);
  } else {
  Glide.with(convertView.getContext()).load(Limage).centerCrop()
  .diskCacheStrategy(DiskCacheStrategy.ALL).listener(new RequestListener&lt;String, GlideDrawable&gt;() {
                             @Override
                             public boolean onException(Exception e, String model, Target&lt;GlideDrawable&gt; target, boolean isFirstResource) {
                                 return false;
                             }
  
                             @Override
                             public boolean onResourceReady(GlideDrawable resource, String model, Target&lt;GlideDrawable&gt; target, boolean isFromMemoryCache, boolean isFirstResource) {
  
                               //  viewholder.progress.setVisibility(View.GONE);
                                 return false;
                             }
                         }).into(viewholder.iview);
              viewholder.iview.setVisibility(View.VISIBLE);
          }
  </code></pre>
  
  <p>I have created a Share button and inside onclick i am passing the below code. </p>
  
  <pre><code>viewholder.share.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Uri bmpUri = getLocalBitmapUri(viewholder.iview);
                  if (bmpUri != null) {
                      // Construct a ShareIntent with link to image
                      Intent shareIntent = new Intent();
                      shareIntent.setAction(Intent.ACTION_SEND);
                      shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
                      shareIntent.setType("image/*");
                      // Launch sharing dialog for image
                      listdisplay.startActivity(Intent.createChooser(shareIntent, "Share Image"));
  
                  } else {
                      // ...sharing failed, handle error
                  }
  
              }
          });
  </code></pre>
  
  <p>To get image from Imageview i am using the below code. </p>
  
  <pre><code>   private Uri getLocalBitmapUri(ImageView iview) {
          Drawable drawable = iview.getDrawable();
          Bitmap bmp = null;
          if (drawable instanceof BitmapDrawable){
  
              bmp = ((BitmapDrawable) iview.getDrawable()).getBitmap();
  
                  Log.e("Shiva","Came inside drawable");
          } else {
              Log.e("Shiva","drawable is null"+drawable);
              return null;
  
          }
  
          Uri bmpUri = null;
  
          File file =  new File(listdisplay.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "share_image_" + System.currentTimeMillis() + ".png");
          FileOutputStream out = null;
          try {
              out = new FileOutputStream(file);
              bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
              out.close();
              bmpUri = Uri.fromFile(file);
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          // **Warning:** This will fail for API &gt;= 24, use a FileProvider as shown below instead.
  
     return bmpUri;
  
      }
  </code></pre>
  
  <p>So, what happened now is in the if step where it is checking "drawable instanceof BitmapDrawable" is always returns null. whats wrong here? 
  Note: Above code are inside the adapter. </p>