title: Send image from one activity to another activity imageview
body: <p>In the first activity the camera is open in the surfaceview and on click on the capture button when the image is clicked its preview is shown on the next activity of the imageview.Plz help me </p>
  
  <p>My First Activity:</p>
  
  <p>public class CodeActivity extends Activity implements SurfaceHolder.Callback{</p>
  
  <pre><code>Button btn;
  ImageView imgss;
  public static final int SELECT_PICTURE = 1;
  String selectedImagePath;
  Context context;
  Bitmap image;
  Bundle bundle;
  Intent intent;
  String pictureFile;
  String fileName;
  private static int RESULT_LOAD_IMAGE = 1;
  
  SurfaceView surfaceView;
  SurfaceHolder surfaceHolder;
  boolean previewing = false;
  //public static final int SELECT_PICTURE = 1;
  private Camera mCamera;
  //private CameraPreview mPreview;
  private PictureCallback mPicture;
  private Button capture, switchCamera;
  private Context myContext;
  //private LinearLayout cameraPreview;
  private boolean cameraFront = false;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_code);
      myContext = this;
      context = this;
  
       //getWindow().setFormat(PixelFormat.UNKNOWN);
          surfaceView = (SurfaceView)findViewById(R.id.surfaceView1);
          surfaceHolder = surfaceView.getHolder();
          surfaceHolder.addCallback(this);
          surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
  
      btn = (Button)findViewById(R.id.button1);
      imgss = (ImageView) findViewById(R.id.imageView1);
  
      btn.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
                /* Intent i = new Intent(
                          Intent.ACTION_PICK,
                          android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  
                  startActivityForResult(i, RESULT_LOAD_IMAGE);*/
  
              mCamera.takePicture(null, null,  myPictureCallback_JPG);
  
  
          }
      });
  
      imgss.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
          //sendImage();  
          }
      });
  
  
  
  
  }
  
  
  /*PictureCallback myPictureCallback_JPG = new PictureCallback() {
      public void onPictureTaken(byte[] data, Camera camera) {
          Bitmap bitmapPicture = BitmapFactory.decodeByteArray(data,0,data.length);
          File imageDirectory = new File(Environment.getExternalStorageDirectory() + File.separator + "surbeyImg");
          imageDirectory.mkdirs();
          File imgName = null;
          File f = new File(Environment.getExternalStorageDirectory()
           + File.separator + "surbeyImg" + File.separator + imgName+".jpg");
           try 
           {
                  f.createNewFile();
                  //write the bytes in file
                  FileOutputStream fo = new FileOutputStream(f);
                  fo.write(data);
            } catch (IOException e) 
            {
              e.printStackTrace();
            }
          Intent intentImg = new Intent(CodeActivity.this, PassActivity.class);
           intentImg.putExtra("img",imgName);
           startActivity(intentImg); 
  
      }
  };*/
  
  
  /*PictureCallback myPictureCallback_JPG = new PictureCallback() {
      public void onPictureTaken(byte[] data, Camera camera) {
          String fileName = "tempIMG.png";
          try {
              FileOutputStream fileOutStream = openFileOutput(fileName, MODE_PRIVATE);
              fileOutStream.write(data);
              fileOutStream.close();
          } catch (IOException ioe) {
              ioe.printStackTrace();
          }
          Intent i = new Intent(context, PassActivity.class);
  
          Bundle bundle = new Bundle();
          bundle.putByteArray("photo", fileName);
          i.putExtras(bundle);
          startActivity(i);
      }
  </code></pre>
  
  <p>};*/</p>
  
  <pre><code>PictureCallback  myPictureCallback_JPG = new PictureCallback() {
  public void onPictureTaken(byte[] data, Camera camera) {
      Intent i = new Intent(context, PassActivity.class);
  
      Bundle bundle = new Bundle();
      bundle.putByteArray("photo", data);
      i.putExtras(bundle);
      startActivity(i);
  }
  </code></pre>
  
  <p>};</p>
  
  <p>My Next Activity:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_pass);
  
  
      /*imgss = (ImageView) findViewById(R.id.imagereceieve);
      btn = (Button)findViewById(R.id.button1);
  
      Bundle extras = getIntent().getExtras();
      String photoPath = extras.getString("photoPath");
      File filePath = getFileStreamPath(photoPath);
  
      imgss.setImageBitmap(BitmapFactory.decodeFile(photoPath));*/
  
  
      Bundle extras = getIntent().getExtras();
      byte[] photo = extras.getByteArray("photo");
  
  
      Bitmap bitmap  = decodeByteArray (photo, 0, photo.length);
      ImageView imgView = (ImageView)findViewById(R.id.imagereceieve);
      imgView.setImageBitmap(bitmap);
  </code></pre>