title: Share images from gallery in Android
body: <p>i have written a program which has two buttons , one is for gallery which when clicked displays my images from gallery and another button which starts my camera which displays the captured images. </p>
  
  <p>The images are getting displayed properly , but I am not able to understand how to share the displayed images to other apps , please need some help.</p>
  
  <p>Below here is my code for sharing : I have put question mark because i need to know what i should pass inside my Uri so that i can get the path of my images </p>
  
  <pre><code>imgShare.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              Intent intent = new Intent(Intent.ACTION_SEND);
              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
              intent.setType("image/*");
              Uri selectedImage = ????
              intent.putExtra(Intent.EXTRA_STREAM, selectedImage);
              startActivityForResult(
                      Intent.createChooser(intent, "Select Picture"),
                      SELECT_PICTURE);
  
  
          }
  </code></pre>
  
  <p>My code for startActivityForResult</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // TODO Auto-generated method stub
  
      if (requestCode == SELECT_PICTURE &amp;&amp; resultCode == RESULT_OK
              &amp;&amp; null != data) {
  
          // Toast.makeText(getBaseContext(),
          // "File saved at " + imageFile.getAbsolutePath(),
          // Toast.LENGTH_SHORT).show();
          Uri selectedImage = data.getData();
          String[] filePathColumn = { MediaStore.Images.Media.DATA };
  
          Cursor cursor = getContentResolver().query(selectedImage,
                  filePathColumn, null, null, null);
          cursor.moveToFirst();
  
          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String picturePath = cursor.getString(columnIndex);
          cursor.close();
  
          BitmapFactory.Options options = new BitmapFactory.Options();
          options.inPreferredConfig = Bitmap.Config.ARGB_8888;
          /*
           * Bitmap bitmap = BitmapFactory .decodeFile( Environment
           * .getExternalStoragePublicDirectory
           * (Environment.DIRECTORY_PICTURES) + File.separator + ".jpg",
           * options);
           */
          Bitmap bitmap = BitmapFactory.decodeFile(picturePath);
          int newWidth = bitmap.getWidth();
          int newHeight = bitmap.getHeight();
  
          while (newWidth &gt; 1200) {
              newWidth = newWidth / 2;
              newHeight = newHeight / 2;
          }
          img.setImageBitmap(Bitmap.createScaledBitmap(bitmap, newWidth,
                  newHeight, false));
  
      }
  </code></pre>
  
  <p>any suggestions are welcomed , thanking you</p>