Files
DrunkDial/Components/xamarin.mobile-0.7.7.info
Tommy Parnell 09b555d296 init
2016-01-22 22:28:01 -05:00

1 line
7.2 KiB
Plaintext

{"Name":"Xamarin.Mobile","Id":2138,"Alias":"xamarin.mobile","Description":"Xamarin.Mobile is an API for accessing common platform features, such as\r\nreading the user\u0027s address book and using the camera, across iOS,\r\nAndroid, and Windows Phone.\r\n\r\nThe goal of Xamarin.Mobile is to decrease the amount of\r\nplatform-specific code needed to perform common tasks in multiplatform\r\napps, making development simpler and faster.\r\n\r\nXamarin.Mobile is currently a preview release and is subject to API\r\nchanges.\r\n\r\n**Note:** The Windows Phone 7.1 version of the library requires the\r\nMicrosoft.Bcl.Async NuGet package. You\u0027ll need to restore this package\r\nto use the samples or download this package to any WP7 app using\r\nXamarin.Mobile.\r\n\r\n## Examples\r\n\r\nTo access the address book (requires `READ_CONTACTS` permissions\r\non Android):\r\n\r\n```csharp\r\nusing Xamarin.Contacts;\r\n// ...\r\n\r\nvar book = new Xamarin.Contacts.AddressBook ();\r\n// new AddressBook (this); on Android\r\nif (!await book.RequestPermission()) {\r\n\tConsole.WriteLine (\"Permission denied by user or manifest\");\r\n\treturn;\r\n}\r\n\r\nforeach (Contact contact in book.OrderBy (c =\u003e c.LastName)) {\r\n\tConsole.WriteLine (\"{0} {1}\", contact.FirstName, contact.LastName);\r\n}\r\n```\r\n\r\nTo get the user\u0027s location (requires `ACCESS_COARSE_LOCATION` and\r\n`ACCESS_FINE_LOCATION` permissions on Android):\r\n\r\n```csharp\r\nusing Xamarin.Geolocation;\r\n// ...\r\n\r\nvar locator = new Geolocator { DesiredAccuracy = 50 };\r\n// new Geolocator (this) { ... }; on Android\r\n\r\nPosition position = await locator.GetPositionAsync (timeout: 10000);\r\n\r\nConsole.WriteLine (\"Position Status: {0}\", position.Timestamp);\r\nConsole.WriteLine (\"Position Latitude: {0}\", position.Latitude);\r\nConsole.WriteLine (\"Position Longitude: {0}\", position.Longitude);\r\n```\r\n\r\nTo take a photo:\r\n\r\n```csharp\r\nusing Xamarin.Media;\r\n// ...\r\n\r\nvar picker = new MediaPicker ();\r\nif (!picker.IsCameraAvailable)\r\n\tConsole.WriteLine (\"No camera!\");\r\nelse {\r\n\ttry {\r\n\t\tMediaFile file = await picker.TakePhotoAsync (new StoreCameraMediaOptions {\r\n\t\t\tName = \"test.jpg\",\r\n\t\t\tDirectory = \"MediaPickerSample\"\r\n\t\t});\r\n\r\n\t\tConsole.WriteLine (file.Path);\r\n\t} catch (OperationCanceledException) {\r\n\t\tConsole.WriteLine (\"Canceled\");\r\n\t}\r\n}\r\n```\r\n\r\nOn Android (requires `WRITE_EXTERNAL_STORAGE` permissions):\r\n\r\n```csharp\r\nusing Xamarin.Media;\r\n// ...\r\n\r\nprotected override void OnCreate (Bundle bundle)\r\n{\r\n\tvar picker = new MediaPicker (this);\r\n\tif (!picker.IsCameraAvailable)\r\n\t\tConsole.WriteLine (\"No camera!\");\r\n\telse {\r\n\t\tvar intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {\r\n\t\t\tName = \"test.jpg\",\r\n\t\t\tDirectory = \"MediaPickerSample\"\r\n\t\t});\r\n\t\tStartActivityForResult (intent, 1);\r\n\t}\r\n}\r\n\r\nprotected override async void OnActivityResult (int requestCode, Result resultCode, Intent data)\r\n{\r\n\t// User canceled\r\n\tif (resultCode == Result.Canceled)\r\n\t\treturn;\r\n\r\n\tMediaFile file = await data.GetMediaFileExtraAsync (this);\r\n\tConsole.WriteLine (file.Path);\r\n}\r\n```","Version":"0.7.7","Summary":"Xamarin.Mobile is a library that exposes a single set of APIs for accessing common mobile device functionality across iOS, Android and Windows platforms.","QuickStart":"## Examples\n\n### Contacts\nTo access the address book (requires `READ_CONTACTS` permissions\non Android):\n\n```csharp\nusing Xamarin.Contacts;\n// ...\n\nvar book = new Xamarin.Contacts.AddressBook ();\nbook.RequestPermission().ContinueWith (t =\u003e {\n\tif (!t.Result) {\n\t\tConsole.WriteLine (\"Permission denied by user or manifest\");\n\t\treturn;\n\t}\n\n\tforeach (Contact contact in book.OrderBy (c =\u003e c.LastName)) {\n\t\tConsole.WriteLine (\"{0} {1}\", contact.FirstName, contact.LastName);\n\t}\n}, TaskScheduler.FromCurrentSynchronizationContext());\n```\n\n### Geolocation\n\nTo get the user\u0027s location (requires `ACCESS_COARSE_LOCATION` and\n`ACCESS_FINE_LOCATION` permissions on Android):\n\n```csharp\nusing Xamarin.Geolocation;\n// ...\n\nvar locator = new Geolocator { DesiredAccuracy = 50 };\n// new Geolocator (this) { ... }; on Android\nlocator.GetPositionAsync (timeout: 10000).ContinueWith (t =\u003e {\n\tConsole.WriteLine (\"Position Status: {0}\", t.Result.Timestamp);\n\tConsole.WriteLine (\"Position Latitude: {0}\", t.Result.Latitude);\n\tConsole.WriteLine (\"Position Longitude: {0}\", t.Result.Longitude);\n}, TaskScheduler.FromCurrentSynchronizationContext());\n```\n\nNOTE: On iOS 8.0+ you must set either `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in your `Info.plist` file so that Xamarin.Mobile will request the appropriate permission from the user.\n\n### Media\n\n`MediaPicker` allows you to invoke the native UI to take or select photos or video. Given\nthat there is this UI interaction, the code (while simpler than doing it manually) will not\nbe completely cross-platform.\n\nTo take a photo on iOS, Windows Phone or WinRT:\n\n```csharp\nusing Xamarin.Media;\n// ...\n\nvar picker = new MediaPicker();\npicker.PickPhotoAsync().ContinueWith (t =\u003e {\n\tMediaFile file = t.Result;\n\tConsole.WriteLine (file.Path);\n}, TaskScheduler.FromCurrentSynchronizationContext());\n```\n\nOn Android and optionally on iOS, you control the UI.\n\nTo take a photo on Android (requires `WRITE_EXTERNAL_STORAGE` permissions):\n\n```csharp\nusing Xamarin.Media;\n// ...\n\nprotected override void OnCreate (Bundle bundle)\n{\n\tvar picker = new MediaPicker (this);\n\tif (!picker.IsCameraAvailable)\n\t\tConsole.WriteLine (\"No camera!\");\n\telse {\n\t\tvar intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {\n\t\t\tName = \"test.jpg\",\n\t\t\tDirectory = \"MediaPickerSample\"\n\t\t});\n\t\tStartActivityForResult (intent, 1);\n\t}\n}\n\nprotected override void OnActivityResult (int requestCode, Result resultCode, Intent data)\n{\n\t// User canceled\n\tif (resultCode == Result.Canceled)\n\t\treturn;\n\n\tdata.GetMediaFileExtraAsync (this).ContinueWith (t =\u003e {\n\t\tConsole.WriteLine (t.Result.Path);\n\t}, TaskScheduler.FromCurrentSynchronizationContext());\n}\n```\n\nTo take a photo on iOS controlling the UI:\n\n```csharp\nusing Xamarin.Media;\n// ...\n\nvar picker = new MediaPicker();\nMediaPickerController controller = picker.GetTakePhotoUI (new StoreCameraMediaOptions {\n\tName = \"test.jpg\",\n\tDirectory = \"MediaPickerSample\"\n});\n\n// On iPad, you\u0027ll use UIPopoverController to present the controller\nPresentViewController (controller, true, null);\n\ncontroller.GetResultAsync().ContinueWith (t =\u003e {\n\t// Dismiss the UI yourself\n\tcontroller.DismissViewController (true, () =\u003e {\n\t\tMediaFile file = t.Result;\n\t});\n\t\n}, TaskScheduler.FromCurrentSynchronizationContext());\n```\n#####Note to iOS 8 Developers\nShowing a `MediaPicker` in response to a `UIActionSheet.Clicked` event will cause unexpected behavior on iOS 8. Apps should be updated to conditionally use an `UIAlertController` with a style of `UIAlertControllerStyle.ActionSheet.` See the iOS sample for more info. \n\n\n","Hash":"e43b605338b1b263d954ba604905aa53","TargetPlatforms":["ios","android"],"TrialHash":null}