SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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...
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

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

Hinweis der Redaktion

  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