This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
Releases: xamarin/Xamarin.Mobile
Releases · xamarin/Xamarin.Mobile
v0.7.1-preview
Fixes:
v0.7-preview
Significant changes
- New APIs for controlling MediaPicker UI on iOS and Android
iOS:
var picker = new MediaPicker();
MediaPickerController pickerController = picker.GetPickPhotoUI();
myController.PresentViewController (mediaPickerController, true, null);
pickerController.GetResultAsync().ContinueWith (t => {
// We need to dismiss the controller ourselves
myController.DismissViewController (true, () => {
// User canceled or something went wrong
if (t.IsCanceled || t.IsFaulted)
return;
// We get back a MediaFile
MediaFile media = t.Result;
ShowPhoto (media);
});
// Make sure we use the UI thread to show our photo.
}, TaskScheduler.FromCurrentSynchronizationContext());
Android:
void TakePhoto()
{
var picker = new MediaPicker (this);
Intent intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
Name = "test.jpg",
Directory = "MediaPickerSample"
});
StartActivityForResult (intent, 1);
}
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
{
// User canceled
if (resultCode == Result.Canceled)
return;
data.GetMediaFileExtraAsync (this).ContinueWith (t => {
ShowPhoto (t.Result.Path);
}, TaskScheduler.FromCurrentSynchronizationContext());
}
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. It will continue to be the only API for Windows Phone and Windows 8 and be present along with the new API for iOS.
Fixes: