SlideShare a Scribd company logo
1 of 22
Download to read offline
Mike Bluestein
Developer/Writer
Xamarin
mike.bluestein@xamarin.com
Xamarin.Mobile API
@mikebluestein
Xamarin.Mobile
• Cross Platform API
Xamarin.iOS
Xamarin.Android
Windows Store Applications
Windows Phone 8
Windows Phone 7.1
• Abstracts common device features
Now Open Source!
Architecture
Contacts
Xamarin.Mobile
Geolocation Camera
Contacts
Contacts
• AddressBook
RequestPermission
• Contact
Phone
Email
Address
Website
Relationship
Contacts
• Maps to native implementation on each platform
• AddressBook implements IQueryable
• LINQ
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);
Contacts - iOS
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();
}
Xamarin.Mobile Contacts
var book = new AddressBook ();
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);
}
Geolocation
Geolocation
• Geolocator
• Position
Latitude
Longitude
Accuracy
Altitude
Altitude Accuracy
Heading
Geolocation
• Geolocator class
• Retrieve current location
• Listen for Location changes
• DesiredAccuracy influences the location technology that is used
MediaPicker
MediaPicker
• Take Photos and Videos
• Select Photos and Videos
• Programmatic feature detection
MediaPicker.PhotosSupported
MediaPicker.VideosSupported
MediaPicker. IsCameraAvailable
MediaPicker Camera
• Specify which camera to use
• Specify video quality
• Async and C# TPL Compatible
Task.ContinueWith, IsCancelled, IsFaulted
MediaPicker iOS
var picker = new MediaPicker();
MediaPickerController controller = picker.GetTakePhotoUI (new
StoreCameraMediaOptions {
Name = "test.jpg",
Directory = "MediaPickerSample"
});
PresentViewController (controller, true, null);
controller.GetResultAsync().ContinueWith (t => {
// Dismiss the UI yourself
controller.DismissViewController (true, () => {
MediaFile file = t.Result;
});
}, TaskScheduler.FromCurrentSynchronizationContext());
MediaPicker Android
var picker = new MediaPicker (this);
if (!picker.IsCameraAvailable)
Console.WriteLine ("No camera!");
else {
var intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions {
Name = "test.jpg",
Directory = "MediaPickerSample"
});
StartActivityForResult (intent, 1);
}
MediaPicker Android
protected override void OnActivityResult (int requestCode, Result resultCode,
Intent data)
{
// User canceled
if (resultCode == Result.Canceled)
return;
data.GetMediaFileExtraAsync (this).ContinueWith (t => {
if (requestCode == 1) { // Video request
ShowVideo (t.Result.Path);
} else if (requestCode == 2) { // Image request
ShowImage (t.Result.Path);
}
}, TaskScheduler.FromCurrentSynchronizationContext());
}
var mediaPickerController = mediaPicker.GetPickPhotoUI();
mediaPickerController.GetResultAsync()
.ContinueWith (t => {
mediaPickerController.DismissViewController (
true, () => {
// User canceled or something went wrong
if (t.IsCanceled || t.IsFaulted)
return;
// We get back a MediaFile
MediaFile media = t.Result;
});
}, TaskScheduler.FromCurrentSynchronizationContext());
MediaPicker Selecting Photos
Demo
Resources
xamarin.com/mobileapi

More Related Content

Similar to Xamarin mobile

Programming iOS in C#
Programming iOS in C#Programming iOS in C#
Programming iOS in C#Frank Krueger
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideJames Montemagno
 
Xamarin.Forms - More Productive & Beautiful Than Ever
Xamarin.Forms - More Productive & Beautiful Than EverXamarin.Forms - More Productive & Beautiful Than Ever
Xamarin.Forms - More Productive & Beautiful Than EverJefferson Balivo
 
ArchitectNow - Real World Xamarin Overview
ArchitectNow - Real World Xamarin OverviewArchitectNow - Real World Xamarin Overview
ArchitectNow - Real World Xamarin OverviewKevin Grossnicklaus
 
What's new and next for mobile development with .NET
What's new and next for mobile development with .NETWhat's new and next for mobile development with .NET
What's new and next for mobile development with .NETJames Montemagno
 
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, Microsoft
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, MicrosoftSmau Milano 2016 - Erica Barone e Lorenzo Barbieri, Microsoft
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, MicrosoftSMAU
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...Matt Spradley
 
Share more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesShare more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesDan Ardelean
 
TechEd Europe 2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
TechEd Europe  2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudioTechEd Europe  2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
TechEd Europe 2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudioJames Montemagno
 
Developing Cross-platform Native Apps with Xamarin
Developing Cross-platform Native Apps with XamarinDeveloping Cross-platform Native Apps with Xamarin
Developing Cross-platform Native Apps with Xamarindanhermes
 
Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4Xamarin
 
What's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoWhat's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoJames Montemagno
 
MS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentMS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentJames Montemagno
 
Xamarin Dev Days - Introduction to Xamarin
Xamarin Dev Days - Introduction to XamarinXamarin Dev Days - Introduction to Xamarin
Xamarin Dev Days - Introduction to XamarinJames Montemagno
 
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBess Ho
 
Xamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationXamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationJames Montemagno
 
Xamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudXamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudEmanuel Amiguinho
 

Similar to Xamarin mobile (20)

Programming iOS in C#
Programming iOS in C#Programming iOS in C#
Programming iOS in C#
 
Introduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet WestideIntroduction to Mobile Development with Xamarin -DotNet Westide
Introduction to Mobile Development with Xamarin -DotNet Westide
 
Xamarin.Forms - More Productive & Beautiful Than Ever
Xamarin.Forms - More Productive & Beautiful Than EverXamarin.Forms - More Productive & Beautiful Than Ever
Xamarin.Forms - More Productive & Beautiful Than Ever
 
ArchitectNow - Real World Xamarin Overview
ArchitectNow - Real World Xamarin OverviewArchitectNow - Real World Xamarin Overview
ArchitectNow - Real World Xamarin Overview
 
What's new and next for mobile development with .NET
What's new and next for mobile development with .NETWhat's new and next for mobile development with .NET
What's new and next for mobile development with .NET
 
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, Microsoft
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, MicrosoftSmau Milano 2016 - Erica Barone e Lorenzo Barbieri, Microsoft
Smau Milano 2016 - Erica Barone e Lorenzo Barbieri, Microsoft
 
Wake Up
Wake UpWake Up
Wake Up
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
 
Introduction to Xamarin
Introduction to XamarinIntroduction to Xamarin
Introduction to Xamarin
 
Share more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesShare more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class Libraries
 
Xamarin - Beyond the Basics
Xamarin - Beyond the BasicsXamarin - Beyond the Basics
Xamarin - Beyond the Basics
 
TechEd Europe 2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
TechEd Europe  2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudioTechEd Europe  2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
TechEd Europe 2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
 
Developing Cross-platform Native Apps with Xamarin
Developing Cross-platform Native Apps with XamarinDeveloping Cross-platform Native Apps with Xamarin
Developing Cross-platform Native Apps with Xamarin
 
Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4Native i os, android, and windows development in c# with xamarin 4
Native i os, android, and windows development in c# with xamarin 4
 
What's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo DomingoWhat's New in Xamarin? - Santo Domingo
What's New in Xamarin? - Santo Domingo
 
MS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile DevelopmentMS Experiences 17 - Xamarin: Future of Mobile Development
MS Experiences 17 - Xamarin: Future of Mobile Development
 
Xamarin Dev Days - Introduction to Xamarin
Xamarin Dev Days - Introduction to XamarinXamarin Dev Days - Introduction to Xamarin
Xamarin Dev Days - Introduction to Xamarin
 
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
 
Xamarin.forms Shell + Navigation
Xamarin.forms Shell + NavigationXamarin.forms Shell + Navigation
Xamarin.forms Shell + Navigation
 
Xamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test CloudXamarin UI Test And Xamarin Test Cloud
Xamarin UI Test And Xamarin Test Cloud
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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 Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
🐬 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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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 Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Xamarin mobile

  • 2. Xamarin.Mobile • Cross Platform API Xamarin.iOS Xamarin.Android Windows Store Applications Windows Phone 8 Windows Phone 7.1 • Abstracts common device features
  • 7. Contacts • Maps to native implementation on each platform • AddressBook implements IQueryable • LINQ
  • 8. 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); Contacts - iOS
  • 9. 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(); }
  • 10. Xamarin.Mobile Contacts var book = new AddressBook (); 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); }
  • 13. Geolocation • Geolocator class • Retrieve current location • Listen for Location changes • DesiredAccuracy influences the location technology that is used
  • 15. MediaPicker • Take Photos and Videos • Select Photos and Videos • Programmatic feature detection MediaPicker.PhotosSupported MediaPicker.VideosSupported MediaPicker. IsCameraAvailable
  • 16. MediaPicker Camera • Specify which camera to use • Specify video quality • Async and C# TPL Compatible Task.ContinueWith, IsCancelled, IsFaulted
  • 17. MediaPicker iOS var picker = new MediaPicker(); MediaPickerController controller = picker.GetTakePhotoUI (new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }); PresentViewController (controller, true, null); controller.GetResultAsync().ContinueWith (t => { // Dismiss the UI yourself controller.DismissViewController (true, () => { MediaFile file = t.Result; }); }, TaskScheduler.FromCurrentSynchronizationContext());
  • 18. MediaPicker Android var picker = new MediaPicker (this); if (!picker.IsCameraAvailable) Console.WriteLine ("No camera!"); else { var intent = picker.GetTakePhotoUI (new StoreCameraMediaOptions { Name = "test.jpg", Directory = "MediaPickerSample" }); StartActivityForResult (intent, 1); }
  • 19. MediaPicker Android protected override void OnActivityResult (int requestCode, Result resultCode, Intent data) { // User canceled if (resultCode == Result.Canceled) return; data.GetMediaFileExtraAsync (this).ContinueWith (t => { if (requestCode == 1) { // Video request ShowVideo (t.Result.Path); } else if (requestCode == 2) { // Image request ShowImage (t.Result.Path); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
  • 20. var mediaPickerController = mediaPicker.GetPickPhotoUI(); mediaPickerController.GetResultAsync() .ContinueWith (t => { mediaPickerController.DismissViewController ( true, () => { // User canceled or something went wrong if (t.IsCanceled || t.IsFaulted) return; // We get back a MediaFile MediaFile media = t.Result; }); }, TaskScheduler.FromCurrentSynchronizationContext()); MediaPicker Selecting Photos
  • 21. Demo