onActivityResult not thrown with MediaStore.ACTION_IMAGE_CAP

All your problems with Audio, Video and Images.

onActivityResult not thrown with MediaStore.ACTION_IMAGE_CAP

Postby Steph » Tue Jun 14, 2011 8:35 pm

Hi everybody,

I 'm currently trying to get photo for my app but i have a problem. Photo is correctly save in my folder, but when camera app stopped it doesn't throw onActivityResult.
I really don't understand why.

If you have an idea, feel free to help me.

Thanks in advance.

(i have all the right in manifest)

Code: Select all
public void onClick(View v) {
      case R.id.addPhoto:
         Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
         intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(this)) );
         startActivityForResult(intent, 100);//100 is code for photo

   private File getTempFile(Context context){
     //it will return /sdcard/image.tmp
     final File path = new File( Environment.getExternalStorageDirectory(), getString(R.string.app_name));
     return new File(path, "image"+Math.random()+".bmp");

   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (resultCode == RESULT_OK) {
         case 100:
            final File file = getTempFile(this);
            try {
               Bitmap captureBmp = Media.getBitmap(getContentResolver(), Uri.fromFile(file) );
            } catch (Exception e) {
               Log.e("s", "Add onActivityResult exception took photo",e);
            super.onActivityResult(requestCode, resultCode, data);
Experienced Developer
Experienced Developer
Posts: 90
Joined: Mon Oct 20, 2008 1:48 pm
Location: France


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 20 guests