I want to pass captured camera image and select image from gallery, image should be display in next activity for captured image my code is working fine..but select image from gallery the image is not displaying in the activity..
First Activity
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_CAMERA) {
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]);
//file path of captured image
imagepath = cursor.getString(columnIndex);
//file path of captured image
File f = new File(imagepath);
String filename = f.getName();
/*Toast.makeText(Contact.this, "Your Path:"+imagepath, 2000).show();
Toast.makeText(Contact.this, "Your Filename:"+filename, 2000).show();*/
cursor.close();
//Log.i("image path", imagepath);
Bitmap imageData = BitmapFactory.decodeFile(imagepath);
// Bitmap imageData = null;
imageData = (Bitmap) data.getExtras().get("data");
Intent i = new Intent(this, Cam.class);
i.putExtra("name", imageData );
startActivity(i);
//imageview.setImageBitmap(bit);
}
else if (requestCode == SELECT_FILE) {
//Bitmap photo = (Bitmap) data.getData().getPath();
Uri selectedImageUri = data.getData();
imagepath = getPath(selectedImageUri, null);
// your bitmap
//ByteArrayOutputStream bs = new ByteArrayOutputStream();
Bitmap imageData = BitmapFactory.decodeFile(imagepath);
imageData = (Bitmap) data.getExtras().get("data");
Intent intent = new Intent(this, Cam.class);
intent.putExtra("name", imageData );
startActivity(intent);
Second Activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cam);
Bitmap bitmap = getIntent().getExtras().getParcelable("name");
ImageView view = (ImageView) findViewById(R.id.imageView1);
view.setImageBitmap(bitmap);
}