The latest release of Xamarin.Mobile component obsoletes some Task-based APIs for Android. Release notes briefly comment on this:
Given the fragility of the Task<> based API on Android due to Activity lifecycle realities, the async API is now marked [Obsolete] specifically for Android.
Could someone please explain what fragility is meant here?
Essentially, using
Taskacross app lifecycle boundaries is asking for trouble. When the cameraActivitystarts on Android, you are actually starting a completely new app. Your app is no longer running in the foreground, so Android is completely within its rights to kill off your app and just restart it when the camera returns. If this happens, yourTaskinstance has been destroyed and so anyawaits orContinueWiths you have will never execute. It's not aTask/Android issue, it was simply a design flaw in Xamarin.Mobile.As a result, the magic API was deprecated in favor of one that utilizes
OnActivityResult, as it is the only way to properly handle this situation. If you notice, the new APIGetMediaFileExtraAsyncstill returns aTask<MediaFile>.(Source: I wrote Xamarin.Mobile).