Mediaplugin: Media plugin bug on Android when pressing home and reentering application which calls TakePhotoAsync() again

Created on 29 Jun 2016  路  2Comments  路  Source: jamesmontemagno/MediaPlugin

_From @igorczapski on January 4, 2016 14:44_

Steps to reproduce:

  1. After Activity initialization call:
    var photo = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions{
    Directory = SOME_DIRECTORY,
    Name = SOME_NAME
    });
  2. When you have photo app opened, press HOME button on device.
  3. Reenter the app, go to your activity which calls method above.
  4. InvalidOperationException -> Only one operation can be active at a time.

It doesn't matter if it's Xamarin.Forms or Xamarin.Android, obviously.

Workaround:
In Xamarin.Android just use the standard way with intents and OnActivityResult, or at least you can make some use of intent creation method, from this library.

var media = new MediaImplementation();
var intent = media.GetTakePhotoUI (new Abstractions.StoreCameraMediaOptions {
Directory = DIRECTORY,
Name = NAME
});
StartActivityForResult (intent, ...);

_Copied from original issue: jamesmontemagno/Xamarin.Plugins#174_

Most helpful comment

Hey James, I'm hitting this issue on an Android app, so I tried to reproduce it on the sample available in the repo and it's fairly easy to do it.

  1. Run MediaSample.Droid
  2. Tap on "TAKE PHOTO"
  3. When the camera opens, tap the home button on the device
  4. Tap on the app launcher icon
  5. Tap on "TAKE PHOTO"
  6. 馃挜

Maybe this should be reopened?

All 2 comments

Not able to reproduce

Hey James, I'm hitting this issue on an Android app, so I tried to reproduce it on the sample available in the repo and it's fairly easy to do it.

  1. Run MediaSample.Droid
  2. Tap on "TAKE PHOTO"
  3. When the camera opens, tap the home button on the device
  4. Tap on the app launcher icon
  5. Tap on "TAKE PHOTO"
  6. 馃挜

Maybe this should be reopened?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CesareSoldani picture CesareSoldani  路  6Comments

Furqanali30 picture Furqanali30  路  7Comments

MarcorOnline picture MarcorOnline  路  7Comments

mdcso picture mdcso  路  4Comments

erossini picture erossini  路  3Comments