Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Xamarin.MobileAccessing Unified Cross-Platform Features               June 14, 2012            Copyright 2012 © Xamarin Inc...
AgendaXamarin.Mobile                   Mike Bluestein                   Technical Writer                   Xamarin Documen...
Xamarin.Mobile
Xamarin.Mobile• Cross Platform API
Xamarin.Mobile• Cross Platform API • MonoTouch
Xamarin.Mobile• Cross Platform API • MonoTouch • Mono for Android
Xamarin.Mobile• Cross Platform API • MonoTouch • Mono for Android • Windows Phone 7
Architecture
Architecture   Xamarin.Mobile
Architecture              Xamarin.MobileContacts
Architecture                         Xamarin.MobileContacts   Geolocation
Architecture                         Xamarin.Mobile                          Compass +Contacts   Geolocation              ...
Architecture                         Xamarin.Mobile                          Compass +Contacts   Geolocation              ...
Architecture                         Xamarin.Mobile                          Compass +Contacts   Geolocation              ...
Xamarin.Mobile Contacts
Xamarin.Mobile Contacts • Maps to native implementation on each   platform
Xamarin.Mobile Contacts • Maps to native implementation on each   platform • AddressBook implements IQueryable
Xamarin.Mobile Contacts • Maps to native implementation on each   platform • AddressBook implements IQueryable • LINQ
Contacts - AndroidContentResolver content= getContentResolver();Cursor ncursor = null;try {    ncursor = content.query (Co...
Contacts - iOSABAddressBookRef ab = ABAddressBookCreate();CFStringRef name = CFSTR ("Smith");CFArrayRef smiths = ABAddress...
Xamarin.Mobile Contacts
Xamarin.Mobile Contacts     var book = new AddressBook () {         PreferContactAggregation = true     } ;     foreach (C...
Contacts
MediaPicker
MediaPicker• Take Photos and Videos
MediaPicker• Take Photos and Videos• Select Photos and Videos
MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection
MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection • MediaPicker.PhotosSupported
MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection • MediaPicker.PhotosSupporte...
Selecting Photos
Selecting Photosvar picker = new MediaPicker ();picker.PickPhotoAsync ()     .ContinueWith (t =>     {          if (t.IsCa...
Selecting Photosvar picker = new MediaPicker ();picker.PickPhotoAsync ()     .ContinueWith (t =>     {          if (t.IsCa...
Taking Photos or Videos
Taking Photos or Videos• Specify which camera to use
Taking Photos or Videos• Specify which camera to use• Query for camera availability
Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality
Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality• Async and C# T...
Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality• Async and C# T...
Taking Photos or Videos    if (!picker.IsCameraAvailable)        return;    VideoView videoView = FindViewById<VideoView> ...
MediaPicker
Geolocation
Geolocation• Geolocator class
Geolocation• Geolocator class• Retrieve current location
Geolocation• Geolocator class• Retrieve current location• Listen for Location changes
Geolocation• Geolocator class• Retrieve current location• Listen for Location changes• DesiredAccuracy influences the locat...
Geolocation
Resources• http://xamarin.com/mobileapi• Download:  http://xamarin.com/xamarinmobileapipreview.zip• API Docs:  http://beta...
Xamarin    Seminar   Please give us your feedback  http://bit.ly/xamfeedback      Follow us on Twitter        @XamarinHQ  ...
Prochain SlideShare
Chargement dans…5
×

Xamarin.Mobile - Accessing Unified Cross-platform Features with Mike Bluestein

21 954 vues

Publié le

Video for this session here: http://www.youtube.com/watch?v=VEuMgogl8eY&list=PL35E8B636BEC8411D&index=10&feature=plpp_video

Mike Bluestein will take us through the features of our unified cross-platform API that lets you use the same API to access Contacts, Location and Camera on iOS, Android and Windows Phone 7.

Publié dans : Technologie, Business
  • Soyez le premier à commenter

Xamarin.Mobile - Accessing Unified Cross-platform Features with Mike Bluestein

  1. 1. Xamarin.MobileAccessing Unified Cross-Platform Features June 14, 2012 Copyright 2012 © Xamarin Inc. All rights reserved
  2. 2. AgendaXamarin.Mobile Mike Bluestein Technical Writer Xamarin Documentation Team mike.bluestein@xamarin.com @mikebluestein XamarinCopyright 2012 © Xamarin Inc. All rights reserved
  3. 3. Xamarin.Mobile
  4. 4. Xamarin.Mobile• Cross Platform API
  5. 5. Xamarin.Mobile• Cross Platform API • MonoTouch
  6. 6. Xamarin.Mobile• Cross Platform API • MonoTouch • Mono for Android
  7. 7. Xamarin.Mobile• Cross Platform API • MonoTouch • Mono for Android • Windows Phone 7
  8. 8. Architecture
  9. 9. Architecture Xamarin.Mobile
  10. 10. Architecture Xamarin.MobileContacts
  11. 11. Architecture Xamarin.MobileContacts Geolocation
  12. 12. Architecture Xamarin.Mobile Compass +Contacts Geolocation Accelerometer
  13. 13. Architecture Xamarin.Mobile Compass +Contacts Geolocation Camera Accelerometer
  14. 14. Architecture Xamarin.Mobile Compass +Contacts Geolocation Camera Notifications Accelerometer
  15. 15. Xamarin.Mobile Contacts
  16. 16. Xamarin.Mobile Contacts • Maps to native implementation on each platform
  17. 17. Xamarin.Mobile Contacts • Maps to native implementation on each platform • AddressBook implements IQueryable
  18. 18. Xamarin.Mobile Contacts • Maps to native implementation on each platform • AddressBook implements IQueryable • LINQ
  19. 19. Contacts - AndroidContentResolver content= getContentResolver();Cursor ncursor = null;try { ncursor = content.query (ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data.MIMETYPE, ContactsContract.Contacts.LOOKUP_KEY, ContactsContract.Contacts.DISPLAY_NAME }, ContactsContract.Data.MIMETYPE + "=? AND " + ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME + "=?", new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE, "Smith" }, null); while (ncursor.moveToNext()) { print (ncursor.getString(ncursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)) + lineSep); String lookupKey = ncursor.getString (ncursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Cursor dcursor = null; try { dcursor = content.query (ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.Data.DATA1 }, ContactsContract.Contacts.LOOKUP_KEY + "=?", new String[] { lookupKey }, null); while (dcursor.moveToNext()) { String type = dcursor.getString (ncursor.getColumnIndex(ContactsContract.Data.MIMETYPE)); if (type.equals (ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) print ("Phone: " + dcursor.getString(dcursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)) + lineSep); else if (type.equals (ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)) print ("Email: " + dcursor.getString(dcursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA1)) + lineSep); } } finally { if (dcursor != null) dcursor.close(); } }} finally { if (ncursor != null) ncursor.close();}
  20. 20. Contacts - iOSABAddressBookRef ab = ABAddressBookCreate();CFStringRef name = CFSTR ("Smith");CFArrayRef smiths = ABAddressBookCopyPeopleWithName(ab, name);CFRelease (name);int count = CFArrayGetCount(smiths);for (int i = 0; i < count; ++i) { ABRecordRef person = (ABRecordRef)CFArrayGetValueAtIndex(smiths, (CFIndex)i); if (ABRecordGetRecordType(person) != kABPersonType) continue; NSString *name = (NSString*)ABRecordCopyCompositeName(person); NSLog ("%@n", name); [name release]; ABMultiValueRef phoneNumberProp = ABRecordCopyValue(person, kABPersonPhoneProperty); NSArray* numbers = (NSArray*)ABMultiValueCopyArrayOfAllValues(phoneNumberProp); CFRelease(phoneNumberProp); for (NSString *pvalue in numbers) NSLog ("Phone: %@n", pvalue); [numbers release]; ABMultiValueRef emailProp = ABRecordCopyValue(person, kABPersonEmailProperty); NSArray* emails = (NSArray*)ABMultiValueCopyArrayOfAllValues(emailProp); CFRelease(emailProp); for (NSString *evalue in emails) NSLog ("Email: %@n"); [emails release];}CFRelease (ab);CFRelease (smiths);
  21. 21. Xamarin.Mobile Contacts
  22. 22. Xamarin.Mobile Contacts var book = new AddressBook () { PreferContactAggregation = true } ; foreach (Contact c in book.Where (c => c.LastName == "Smith")) { Console.WriteLine (c.DisplayName); foreach (Phone p in c.Phones) Console.WriteLine ("Phone: " + p.Number); foreach (Email e in c.Emails) Console.WriteLine ("Email: " + e.Address); }
  23. 23. Contacts
  24. 24. MediaPicker
  25. 25. MediaPicker• Take Photos and Videos
  26. 26. MediaPicker• Take Photos and Videos• Select Photos and Videos
  27. 27. MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection
  28. 28. MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection • MediaPicker.PhotosSupported
  29. 29. MediaPicker• Take Photos and Videos• Select Photos and Videos• Programmatic feature detection • MediaPicker.PhotosSupported • MediaPicker.VideosSupported
  30. 30. Selecting Photos
  31. 31. Selecting Photosvar picker = new MediaPicker ();picker.PickPhotoAsync () .ContinueWith (t => { if (t.IsCanceled || t.IsFaulted) // user cancelled or error return; Bitmap b = BitmapFactory.DecodeFile (t.Result.Path); RunOnUiThread (() => platformImage.SetImageBitmap (b)); });
  32. 32. Selecting Photosvar picker = new MediaPicker ();picker.PickPhotoAsync () .ContinueWith (t => { if (t.IsCanceled || t.IsFaulted) // user cancelled or error return; Bitmap b = BitmapFactory.DecodeFile (t.Result.Path); RunOnUiThread (() => platformImage.SetImageBitmap (b)); });
  33. 33. Taking Photos or Videos
  34. 34. Taking Photos or Videos• Specify which camera to use
  35. 35. Taking Photos or Videos• Specify which camera to use• Query for camera availability
  36. 36. Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality
  37. 37. Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality• Async and C# TPL Compatible
  38. 38. Taking Photos or Videos• Specify which camera to use• Query for camera availability• Specify video quality• Async and C# TPL Compatible • Task.ContinueWith, IsCancelled, IsFaulted
  39. 39. Taking Photos or Videos if (!picker.IsCameraAvailable) return; VideoView videoView = FindViewById<VideoView> (Resource.Id.video); picker.TakeVideoAsync (new StoreVideoOptions { Directory = "Xamovies", DefaultCamera = CameraDevice.Front, DesiredLength = TimeSpan.FromMinutes (5) }) .ContinueWith (t => { if (t.IsCanceled || t.IsFaulted) // user cancelled or error return; videoView.SetVideoPath (t.Result.Path); });
  40. 40. MediaPicker
  41. 41. Geolocation
  42. 42. Geolocation• Geolocator class
  43. 43. Geolocation• Geolocator class• Retrieve current location
  44. 44. Geolocation• Geolocator class• Retrieve current location• Listen for Location changes
  45. 45. Geolocation• Geolocator class• Retrieve current location• Listen for Location changes• DesiredAccuracy influences the location technology that is used
  46. 46. Geolocation
  47. 47. Resources• http://xamarin.com/mobileapi• Download: http://xamarin.com/xamarinmobileapipreview.zip• API Docs: http://betaapi.xamarin.com/?link=root:/Xamarin.Mobile
  48. 48. Xamarin Seminar Please give us your feedback http://bit.ly/xamfeedback Follow us on Twitter @XamarinHQ Copyright 2012 © Xamarin Inc. All rights reserved

×