title: Getting current image to share it in Android
body: <p>I have an Android application. In that, the slider is working fine, and the share button is also working correctly.</p>
  
  <p>But, the share button is sharing only an image which I have set in code out of the three total images in slider (since I coded in that way), instead of the current image visible in the slider gallery. I simply want to invoke the share button code with the current image, so that the user can share the current image.</p>
  
  <p>Here are some details,
  3 ImageView for 3 images in the slider. Also, I have taken these in ViewFlipper: </p>
  
  <p>Image 1</p>
  
  <pre><code>       android:id="@+id/imageview1"
         android:tag="bg1"
         android:src="@drawable/image1
  </code></pre>
  
  <p>Image 2</p>
  
  <pre><code>       android:id="@+id/imageview2"
         android:tag="bg2"
         android:src="@drawable/image2
  </code></pre>
  
  <p>Image 3</p>
  
  <pre><code>       android:id="@+id/imageview3"
         android:tag="bg3"
         android:src="@drawable/image3
  </code></pre>
  
  <p>Till now, I have tried this,</p>
  
  <pre><code>    Button btShare = (Button) findViewById(R.id.shareImage);
      btShare.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              share();
          }
      });
  </code></pre>
  
  <p>Now, here's the share() function code snippet, in which I want the current image. For that, I have taken setTag() and getTag(), but I am still confused. 
  Here, I have set the tag for all the 3 images, so that I can get their value.</p>
  
  <pre><code>    mImageView=(ImageView)findViewById(R.id.imageview1);
      mImageView.setTag("bg1");
  
      mImageView=(ImageView)findViewById(R.id.imageview2);
      mImageView.setTag("bg2");
  
      mImageView=(ImageView)findViewById(R.id.imageview3);
      mImageView.setTag("bg3");
  
      String s = String.valueOf(mViewFlipper.getTag());
  
      Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();
  
      if (s.equals("bg1"))  /
      {
          // now the code for share button starts, in that a folder gets
          created in the Directory and a default name is given to the 
          image which gets saved there, like
  
          File f = new File(dir, "savedImage1.png");
  </code></pre>
  
  <p>I am not sure (I don't want to do that either) about the above if-else too, because it isn't good to create "if" for every image, so I need an alternate like an array) or so to work around current Drawable image.</p>
  
  <p>So in the above String s is returning "null", on selecting any image (I checked it by applying Toast and it is showing null in every case). </p>
  
  <p>If I am successful in getting bg1 (for image 1), or bg2 (for image 2), or bg3 (for image 3), for current image in String s, then I can easily run the code to share a particular image only, when it appears on the slider gallery.</p>