i want to pass an image from one activity to another, this is my code:
public boolean launchCamera(View view) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo;
try {
// place where to store camera taken picture
photo = this.createTemporaryFile("picture", ".jpg");
photo.delete();
} catch (Exception e) {
Log.v(TAG, "Can't create file to take picture!");
Toast.makeText(MainActivity.this, "Please check SD card! Image shot is impossible!", Toast.LENGTH_LONG);
return false;
}
mImageUri = Uri.fromFile(photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
//start camera intent
this.startActivityForResult(intent, MenuShootImage);
return true;
}
private File createTemporaryFile(String part, String ext) throws Exception {
File tempDir = Environment.getExternalStorageDirectory();
tempDir = new File(tempDir.getAbsolutePath() + "/.temp/");
if (!tempDir.exists()) {
tempDir.mkdir();
}
return File.createTempFile(part, ext, tempDir);
}
public Bitmap grabImage()
{
this.getContentResolver().notifyChange(mImageUri, null);
ContentResolver cr = this.getContentResolver();
Bitmap bitmap=null;
try
{
bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, mImageUri);
}
catch (Exception e)
{
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT).show();
Log.d(TAG, "Failed to load", e);
}
return bitmap;
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
Intent imagepass = null;
Bitmap bitmap = null;
if(requestCode == MenuShootImage && resultCode == RESULT_OK)
{
bitmap = this.grabImage();
imagepass = new Intent(this,MainActivity2.class);
imagepass.putExtra("imagepass", bitmap );
startActivity(imagepass);
}
}
the problem is that i cant reach to the other activity at all, in debug mode i get to the line startactivity(imagepass); and dont go to the MainActivity2. can somebody help me?