SlideShare a Scribd company logo
1 of 48
Xamarin.Mobile
Accessing Unified Cross-Platform Features




               June 14, 2012

            Copyright 2012 © Xamarin Inc. All rights reserved
Agenda
Xamarin.Mobile

                   Mike Bluestein
                   Technical Writer
                   Xamarin Documentation Team
                   mike.bluestein@xamarin.com
                   @mikebluestein




                                                    Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
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.Mobile




Contacts
Architecture

                         Xamarin.Mobile




Contacts   Geolocation
Architecture

                         Xamarin.Mobile




                          Compass +
Contacts   Geolocation
                         Accelerometer
Architecture

                         Xamarin.Mobile




                          Compass +
Contacts   Geolocation                    Camera
                         Accelerometer
Architecture

                         Xamarin.Mobile




                          Compass +
Contacts   Geolocation                    Camera   Notifications
                         Accelerometer
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 - Android
ContentResolver 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();
}
Contacts - iOS
ABAddressBookRef 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);
Xamarin.Mobile Contacts
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);
     }
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.PhotosSupported
 • MediaPicker.VideosSupported
Selecting Photos
Selecting Photos

var 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));
     });
Selecting Photos

var 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));
     });
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# TPL Compatible
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
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);
    });
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 location
  technology that is used
Geolocation
Resources

• http://xamarin.com/mobileapi
• Download:
  http://xamarin.com/xamarinmobileapipreview.zip

• API Docs:
  http://betaapi.xamarin.com/?link=root:/Xamarin.Mobile
Xamarin
    Seminar
   Please give us your feedback
  http://bit.ly/xamfeedback


      Follow us on Twitter
        @XamarinHQ



        Copyright 2012 © Xamarin Inc. All rights reserved

More Related Content

More from Xamarin

Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureXamarin
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksXamarin
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinXamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningXamarin
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UIXamarin
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesXamarin
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilityXamarin
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeXamarin
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Xamarin
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsXamarin
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureXamarin
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Xamarin
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureXamarin
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Xamarin
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioXamarin
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with XamarinXamarin
 
Building Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppBuilding Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppXamarin
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOpsXamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOpsXamarin
 
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...Xamarin
 

More from Xamarin (20)

Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with Xamarin
 
Building Your First Xamarin.Forms App
Building Your First Xamarin.Forms AppBuilding Your First Xamarin.Forms App
Building Your First Xamarin.Forms App
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOpsXamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
Xamarin Mobile Leaders Summit | Solving the Unique Challenges in Mobile DevOps
 
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
Xamarin Mobile Leaders Summit: The Mobile Mind Shift: Opportunities, Challeng...
 

Recently uploaded

Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideStefan Dietze
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 

Recently uploaded (20)

Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 

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

  • 1. Xamarin.Mobile Accessing Unified Cross-Platform Features June 14, 2012 Copyright 2012 © Xamarin Inc. All rights reserved
  • 2. Agenda Xamarin.Mobile Mike Bluestein Technical Writer Xamarin Documentation Team mike.bluestein@xamarin.com @mikebluestein Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • 6. Xamarin.Mobile • Cross Platform API • MonoTouch • Mono for Android
  • 7. Xamarin.Mobile • Cross Platform API • MonoTouch • Mono for Android • Windows Phone 7
  • 9. Architecture Xamarin.Mobile
  • 10. Architecture Xamarin.Mobile Contacts
  • 11. Architecture Xamarin.Mobile Contacts Geolocation
  • 12. Architecture Xamarin.Mobile Compass + Contacts Geolocation Accelerometer
  • 13. Architecture Xamarin.Mobile Compass + Contacts Geolocation Camera Accelerometer
  • 14. Architecture Xamarin.Mobile Compass + Contacts Geolocation Camera Notifications Accelerometer
  • 16. Xamarin.Mobile Contacts • Maps to native implementation on each platform
  • 17. Xamarin.Mobile Contacts • Maps to native implementation on each platform • AddressBook implements IQueryable
  • 18. Xamarin.Mobile Contacts • Maps to native implementation on each platform • AddressBook implements IQueryable • LINQ
  • 19. Contacts - Android ContentResolver 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. Contacts - iOS ABAddressBookRef 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);
  • 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); }
  • 26. MediaPicker • Take Photos and Videos • Select Photos and Videos
  • 27. MediaPicker • Take Photos and Videos • Select Photos and Videos • Programmatic feature detection
  • 28. MediaPicker • Take Photos and Videos • Select Photos and Videos • Programmatic feature detection • MediaPicker.PhotosSupported
  • 29. MediaPicker • Take Photos and Videos • Select Photos and Videos • Programmatic feature detection • MediaPicker.PhotosSupported • MediaPicker.VideosSupported
  • 31. Selecting Photos var 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. Selecting Photos var 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)); });
  • 34. Taking Photos or Videos • Specify which camera to use
  • 35. Taking Photos or Videos • Specify which camera to use • Query for camera availability
  • 36. Taking Photos or Videos • Specify which camera to use • Query for camera availability • Specify video quality
  • 37. Taking Photos or Videos • Specify which camera to use • Query for camera availability • Specify video quality • Async and C# TPL Compatible
  • 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. 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); });
  • 43. Geolocation • Geolocator class • Retrieve current location
  • 44. Geolocation • Geolocator class • Retrieve current location • Listen for Location changes
  • 45. Geolocation • Geolocator class • Retrieve current location • Listen for Location changes • DesiredAccuracy influences the location technology that is used
  • 47. Resources • http://xamarin.com/mobileapi • Download: http://xamarin.com/xamarinmobileapipreview.zip • API Docs: http://betaapi.xamarin.com/?link=root:/Xamarin.Mobile
  • 48. Xamarin Seminar Please give us your feedback http://bit.ly/xamfeedback Follow us on Twitter @XamarinHQ Copyright 2012 © Xamarin Inc. All rights reserved

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n