SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler 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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Último

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - AvrilIvanti
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 

Último (20)

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - Avril
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 

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