I understand that during the lifecycle of the app, an activity may be put into the background, and essentially be 'put to sleep'. I have code during a normal activity restore, that will recover the data etc.
When I use a method like:
private async void TakePhoto()
{
// Photo requested
var photo = await MediaPicker.CapturePhotoAsync();
// Photo taken
}
If when calling TakePhoto(), the Android device does not fully background the app, the method successfully hits "Photo taken". If the app is fully backgrounded (as soon as the camera app loads in front it decides to free up resources), once the photo is taken, the activity restores itself, but the original method is no longer executing, so I am unable to continue to get the photo response, thus "Photo taken" is never hit.
So my question is, how am I implementing this wrong, given how the Android activity lifecycle works?