title: how to share images using view pager
body: <pre><code>public class EyeLinerActivity extends Activity {
          int position;
          private ShareActionProvider provider;
          ELImageAdapter adapter;
              @Override
              public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_eyeliner);
  
              //ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
              //adapter = new ELImageAdapter(this);
              //viewPager.setAdapter(adapter);
              //ViewPager.setCurrentItem(0);
               ViewPager  pager = (ViewPager) findViewById(R.id.view_pager);
               adapter = new ELImageAdapter(this);
                pager.setAdapter(new ELImageAdapter(this));
      //        ImageView imageView = new ImageView(context);
      //      imageView.setImageResource(GalImages[position]);
      //        if (pager.getAdapter() != null)
      //        pager.setAdapter(adapter);
      //        pager.setCurrentItem(position);
              }
              @SuppressLint("NewApi")
              @Override
              public boolean onCreateOptionsMenu(Menu menu) {
                  getMenuInflater().inflate(R.menu.main, menu);
                  MenuItem shareitem= (MenuItem)menu.findItem(R.id.action_share);
                  ShareActionProvider provider = (ShareActionProvider)shareitem.getActionProvider();  
                  Bitmap bitmap;
                  OutputStream output;
                  //ArrayList&lt;Uri&gt; imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                  bitmap = BitmapFactory.decodeResource(getResources(),adapter.GalImages[position]); 
                  File filepath = Environment.getExternalStorageDirectory();
                  File dir = new File(filepath.getAbsolutePath() + "/Eye Liner/");
                  dir.mkdirs();
                  File file = new File(dir, "Image.png"); 
                  try {
                  Intent share = new Intent(Intent.ACTION_SEND);
                  share.setAction(Intent.ACTION_SEND);
                  share.setType("image/jpeg");
                  output = new FileOutputStream(file);
                  bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
                  output.flush();
                  output.close();
                  Uri uri = Uri.fromFile(file);
  
                  share.putExtra(Intent.EXTRA_STREAM, uri);
                   provider.setShareIntent(share);
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                      }
                   return true;
                      }
  
                  //return super.onCreateOptionsMenu(menu);
  
               private void setShareIntent(Intent intent) {
                      if (provider != null) {
                          provider.setShareIntent(intent);
                      }
                  }
          }
  </code></pre>
  
  <p>adapter.java</p>
  
  <pre><code>public class ELImageAdapter  extends PagerAdapter {
      Context context;
      public int[] GalImages = new int[] {
               R.drawable.l_1,
                  R.drawable.l_2,
                  R.drawable.l_3,
                  R.drawable.l_4,
                  R.drawable.l_5,
                  R.drawable.l_6,
                  R.drawable.l_7,
                  R.drawable.l_8,
                  R.drawable.l_9,
                  R.drawable.l_10,
                  R.drawable.l_11,
                  R.drawable.l_12,
                  R.drawable.l_13,
                  R.drawable.l_14,
                  R.drawable.l_15,
                  R.drawable.l_16,
                  R.drawable.l_17
  
      };
      ELImageAdapter(Context context){
      this.context=context;
      }
      @Override
      public int getCount() {
      return GalImages.length;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
      return view == ((ImageView) object);
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
      ImageView imageView = new ImageView(context);
      int padding = context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
      imageView.setPadding(padding, padding, padding, padding);
      imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      imageView.setImageResource(GalImages[position]);
      ((ViewPager) container).addView(imageView, 0);
      return imageView;
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager) container).removeView((ImageView) object);
      }
      }
  </code></pre>
  
  <p>i want to share images .. and i am using viewpager
  how can i get images ids to share.? as viewpager does not support onclickitemlistener property. kindly suggest how i can get image id to dhare</p>