SlideShare ist ein Scribd-Unternehmen logo
1 von 41
C# for Android and iOS
Xamarin
Inhalt
Sie sind erfahrener C#-Entwickler, die Welt von Android und iOS
reizt Sie aber trotzdem? In dieser Session zeigt Ihnen Rainer Stropek,
wie Sie mit den Xamarin-Tools Ihr C#-Wissen auf diese mobilen
Plattformen mitnehmen können. Rainer stellt Ihnen die Tools vor und
demonstriert an einem durchgängigen Beispiel, wie
plattformübergreifende C#-Codewiederverwendung funktionieren
kann.
Xamarin
Introduction
Agenda
Develop
Xamarin Studio
Visual Studio
Debugging
Example
App dev basics
Native APIs
Azure component
Code sharing
Summary
Key takeaways
Bildquelle:
http://www.xamarin.com
Bildquelle:
Screenshot Xamarin Studio
Bildquelle:
http://www.flickr.com/photos/caveman
_92223/3347745000/
Introduction
What‘s Xamarin and what problems does it solve?
What Problem Does Xamarin Address?
 Need to support a broad range of mobile devices
Different platforms – Android, iOS, Windows Phone
Different devices – smartphones, tablets
 Existing C# knowledge and experience
Skilled C#/.NET developers and existing C#/.NET codebase
 Lack of knowledge about native development
Java, Objective-C
 Can we cover mobile device market with our existing
knowledge and tools?
Potential Solutions
 Build native apps
Requires knowledge about C#, Java, and/or Objective-C
Requires knowledge about the target platform
 Build mobile web sites
Does it feel like a real native app?
Lack of possibilities to fully use the underlying platform?
 Use a cross-platform development tookit
E.g. Phonegap
 Xamarin: Existing tools & knowledge with bridge to native APIs
What is Xamarin?
 Company founded by the initiators of the Mono project
 C# + Runtime + .NET BCL
C# Compiler
Implementation of the Common Language Infrastructure for Linux-based systems
.NET Base Class Library
 Bridges to native API
Callable Wrappers
 Development environments
Xamarin Studio
Visual Studio integration
Component store
• Xamarin is only free for very small apps
• Pricing per year and per developer
• Prices on the right as per Sept. 24th 2013
• For up-to-date prices see Xamarin Store
Pricing
Bridges
public class ContactListCursorAdapter extends BaseAdapter {
private Context mContext;
private List<ContactEntry> mItems = new ArrayList<ContactEntry>();
public ContactListCursorAdapter(
Context context, ArrayList<ContactEntry> items) {
mContext = context;
mItems = items;
}
public int getCount() {
return mItems .size();
}
public Object getItem(int position) {
return mItems .get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
…
}
}
Java Example
Bridges
public class HiveAdapter : BaseAdapter<Hive>
{
private IReadOnlyList<Hive> items = new List<Hive>();
public HiveAdapter(Context context) {
…
}
public override int Count { get { return this.items.Count; } }
public override Hive this[int position] {
get { return this.items[position]; } }
public override long GetItemId(int position) { return
this.items[position].Id; }
public override View GetView(
int position, View convertView, ViewGroup parent)
{
…
}
}
C# Example
getCount becomes Count
property
getItem becomes indexer
getItemId becomes GetItemId
getView becomes GetView
Bridges// JAVA =======================================================
someTextView.setOnClickListener(new View.OnClickListener() {
public void onClick() {
//Do Stuff
}
});
// C# =========================================================
itemTextView.Click += (o, e) => {
// Do Stuff
};
Events
Java Listener Interfaces
become C# events
Wrapper Lifetime
IDisposable
Note that all classes derived
from Java.Lang.Object
implement IDisposable
Linker
Removes unused APIs to
reduce size of app
See Xamarin docs for details
Shared runtime during
debugging
Reduces package size
Speedup app deployment and
startup during debugging
Development
IDEs, Debugging
Xamarin Studio
Works on Windows and Mac
Basics similar to Visual Studio
If you know VS, you will immediately
understand it
By far not that powerful as VS
Identical project/solution file
format
Open project/solution files in both
IDEs as you need it
Visual Studio
Works only on Windows
The full IDE experience you
are used to
Same C# editor
Same UI
Full deployment and
debugging support
Components
Xamarin Components
Full list of components see
Xamarin Components
website
Emulator
Debug and test your app
Android Device Emulator
Not specific to Xamarin
All features, tools, and restrictions of
native Android development apply
ARM or Intel-based images
ARM images are very slow
Recommendation: Intel image with
HAXM
Demo
Hello World!
Sample app in Xamarin Studio and Visual Studio
Comparing the developer
environments
Debugging experience
Sample
Create Project
Create and configure project
Create Project
Setup project dependencies
Data Access Layer
Platform-independent code
Abstract base class
Could be in a separate class library
(PCL)
Use DBConnection to keep code
reusable
Other strategies
Link source files
Use partial classes
Use interfaces to isolate platform-
specific aspects in your code
Conditional compile
Use patterns like MVVM to reduce
amount of platform-specific code
Data Access Layer
Platform-independent code
Implementation for mobile
device
SQLite
Note
Full support for MEF
Async APIs
C# 5 async/await
Data Access Layer
Platform-independent code
Implementation for
SQL Server
Windows Azure SQL Database
Add Data Access
Add existing items
Mobile DAL
implementation
Add UI
UI for each list item
Add Adapter
Data Source for ListView
Note
Use of async/await
Use of Intent
Main Activity
Entry point for your app
Note
Renamed Activity1 to
MainActivity
Change base class to
ListActivity
UI for Details
Add second Activity
UI for Details
Add second Activity
Note
Intent to launch external
program (browser)
UI for Details
Add second Activity
Note
Intent to launch external
program (browser)
Action Bar
Add menu for action bar
Azure Mobile Service
Backend for app in the cloud
Create Azure Mobile
Service
In the background your data is
stored in SQL Server
Azure Mobile Service
Backend for app in the cloud
Add table Hive
In the background you are
creating a table in SQL
Server
Mobile Services does not need
a schema  no need to
create columns in the table
Azure Mobile Service
Backend for app in the cloud
Get URL and application
key
Add Sync Code
Sync triggered by action
bar button
Check Result
Run the app and check
result of sync in
Windows Azure SQL
Database
Summary
Summary
 Great to bring existing C# knowledge to mobile platforms
Existing business logic C# code might be reused
Write once run anywhere is true for most business logic code
 You still have to learn and understand the platform
Activities, Intents, Services, Adapters, Android SDK, etc.
 No or little code sharing for UI markup/code
Can be maximized using MVVM approach
Saves the day.
BASTA 2013 – C# Workshop
F&A
Rainer Stropek
software architects gmbh
rainer@timecockpit.com
http://www.timecockpit.com
@rstropek
Danke für euer Kommen
Mail
Web
Twitter

Weitere ähnliche Inhalte

Was ist angesagt?

ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6Andy Butland
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideVisual Engineering
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101Rich Helton
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Oro Inc.
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptKaty Slemon
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for MainframersRich Helton
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized projectFabio Collini
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed introRich Helton
 

Was ist angesagt? (20)

ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)Adding custom ui controls to your application (1)
Adding custom ui controls to your application (1)
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Spring boot
Spring bootSpring boot
Spring boot
 
Advance JS and oop
Advance JS and oopAdvance JS and oop
Advance JS and oop
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
Spring MVC Basics
Spring MVC BasicsSpring MVC Basics
Spring MVC Basics
 
Spring core
Spring coreSpring core
Spring core
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized project
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed intro
 

Ähnlich wie Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure

Real world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVMReal world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVMGill Cleeren
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code lessAnton Novikau
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)Jose Manuel Pereira Garcia
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
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
 
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...Amit Sheth
 
Refactoring Wunderlist. UA Mobile 2016.
Refactoring Wunderlist. UA Mobile 2016.Refactoring Wunderlist. UA Mobile 2016.
Refactoring Wunderlist. UA Mobile 2016.UA Mobile
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
Mobile Application Declarative Language
Mobile Application Declarative LanguageMobile Application Declarative Language
Mobile Application Declarative LanguageAlexander Evseenko
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgetsBehnam Taraghi
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Lou Sacco
 

Ähnlich wie Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure (20)

Real world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVMReal world apps with Xamarin and MVVM
Real world apps with Xamarin and MVVM
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code less
 
Diving Into Xamarin.Forms
Diving Into Xamarin.Forms Diving Into Xamarin.Forms
Diving Into Xamarin.Forms
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
F# And Silverlight
F# And SilverlightF# And Silverlight
F# And Silverlight
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
Hexagonal architecture in PHP
Hexagonal architecture in PHPHexagonal architecture in PHP
Hexagonal architecture in PHP
 
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
 
Lightning Talk - Xamarin
Lightning Talk - Xamarin Lightning Talk - Xamarin
Lightning Talk - Xamarin
 
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
MobiCloud: Towards Cloud Mobile Hybrid Application Generation using Semantica...
 
Refactoring Wunderlist. UA Mobile 2016.
Refactoring Wunderlist. UA Mobile 2016.Refactoring Wunderlist. UA Mobile 2016.
Refactoring Wunderlist. UA Mobile 2016.
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
Mobile Application Declarative Language
Mobile Application Declarative LanguageMobile Application Declarative Language
Mobile Application Declarative Language
 
Xamarin Development
Xamarin DevelopmentXamarin Development
Xamarin Development
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgets
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014
 

Kürzlich hochgeladen

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Kürzlich hochgeladen (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure

  • 1. C# for Android and iOS Xamarin
  • 2. Inhalt Sie sind erfahrener C#-Entwickler, die Welt von Android und iOS reizt Sie aber trotzdem? In dieser Session zeigt Ihnen Rainer Stropek, wie Sie mit den Xamarin-Tools Ihr C#-Wissen auf diese mobilen Plattformen mitnehmen können. Rainer stellt Ihnen die Tools vor und demonstriert an einem durchgängigen Beispiel, wie plattformübergreifende C#-Codewiederverwendung funktionieren kann.
  • 3. Xamarin Introduction Agenda Develop Xamarin Studio Visual Studio Debugging Example App dev basics Native APIs Azure component Code sharing Summary Key takeaways Bildquelle: http://www.xamarin.com Bildquelle: Screenshot Xamarin Studio Bildquelle: http://www.flickr.com/photos/caveman _92223/3347745000/
  • 4. Introduction What‘s Xamarin and what problems does it solve?
  • 5. What Problem Does Xamarin Address?  Need to support a broad range of mobile devices Different platforms – Android, iOS, Windows Phone Different devices – smartphones, tablets  Existing C# knowledge and experience Skilled C#/.NET developers and existing C#/.NET codebase  Lack of knowledge about native development Java, Objective-C  Can we cover mobile device market with our existing knowledge and tools?
  • 6. Potential Solutions  Build native apps Requires knowledge about C#, Java, and/or Objective-C Requires knowledge about the target platform  Build mobile web sites Does it feel like a real native app? Lack of possibilities to fully use the underlying platform?  Use a cross-platform development tookit E.g. Phonegap  Xamarin: Existing tools & knowledge with bridge to native APIs
  • 7. What is Xamarin?  Company founded by the initiators of the Mono project  C# + Runtime + .NET BCL C# Compiler Implementation of the Common Language Infrastructure for Linux-based systems .NET Base Class Library  Bridges to native API Callable Wrappers  Development environments Xamarin Studio Visual Studio integration Component store
  • 8. • Xamarin is only free for very small apps • Pricing per year and per developer • Prices on the right as per Sept. 24th 2013 • For up-to-date prices see Xamarin Store Pricing
  • 9. Bridges public class ContactListCursorAdapter extends BaseAdapter { private Context mContext; private List<ContactEntry> mItems = new ArrayList<ContactEntry>(); public ContactListCursorAdapter( Context context, ArrayList<ContactEntry> items) { mContext = context; mItems = items; } public int getCount() { return mItems .size(); } public Object getItem(int position) { return mItems .get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { … } } Java Example
  • 10. Bridges public class HiveAdapter : BaseAdapter<Hive> { private IReadOnlyList<Hive> items = new List<Hive>(); public HiveAdapter(Context context) { … } public override int Count { get { return this.items.Count; } } public override Hive this[int position] { get { return this.items[position]; } } public override long GetItemId(int position) { return this.items[position].Id; } public override View GetView( int position, View convertView, ViewGroup parent) { … } } C# Example getCount becomes Count property getItem becomes indexer getItemId becomes GetItemId getView becomes GetView
  • 11. Bridges// JAVA ======================================================= someTextView.setOnClickListener(new View.OnClickListener() { public void onClick() { //Do Stuff } }); // C# ========================================================= itemTextView.Click += (o, e) => { // Do Stuff }; Events Java Listener Interfaces become C# events
  • 12. Wrapper Lifetime IDisposable Note that all classes derived from Java.Lang.Object implement IDisposable
  • 13. Linker Removes unused APIs to reduce size of app See Xamarin docs for details Shared runtime during debugging Reduces package size Speedup app deployment and startup during debugging
  • 15. Xamarin Studio Works on Windows and Mac Basics similar to Visual Studio If you know VS, you will immediately understand it By far not that powerful as VS Identical project/solution file format Open project/solution files in both IDEs as you need it
  • 16. Visual Studio Works only on Windows The full IDE experience you are used to Same C# editor Same UI Full deployment and debugging support
  • 17. Components Xamarin Components Full list of components see Xamarin Components website
  • 18. Emulator Debug and test your app Android Device Emulator Not specific to Xamarin All features, tools, and restrictions of native Android development apply ARM or Intel-based images ARM images are very slow Recommendation: Intel image with HAXM
  • 19. Demo Hello World! Sample app in Xamarin Studio and Visual Studio Comparing the developer environments Debugging experience
  • 21. Create Project Create and configure project
  • 23. Data Access Layer Platform-independent code Abstract base class Could be in a separate class library (PCL) Use DBConnection to keep code reusable Other strategies Link source files Use partial classes Use interfaces to isolate platform- specific aspects in your code Conditional compile Use patterns like MVVM to reduce amount of platform-specific code
  • 24. Data Access Layer Platform-independent code Implementation for mobile device SQLite Note Full support for MEF Async APIs C# 5 async/await
  • 25. Data Access Layer Platform-independent code Implementation for SQL Server Windows Azure SQL Database
  • 26. Add Data Access Add existing items Mobile DAL implementation
  • 27. Add UI UI for each list item
  • 28. Add Adapter Data Source for ListView Note Use of async/await Use of Intent
  • 29. Main Activity Entry point for your app Note Renamed Activity1 to MainActivity Change base class to ListActivity
  • 30. UI for Details Add second Activity
  • 31. UI for Details Add second Activity Note Intent to launch external program (browser)
  • 32. UI for Details Add second Activity Note Intent to launch external program (browser)
  • 33. Action Bar Add menu for action bar
  • 34. Azure Mobile Service Backend for app in the cloud Create Azure Mobile Service In the background your data is stored in SQL Server
  • 35. Azure Mobile Service Backend for app in the cloud Add table Hive In the background you are creating a table in SQL Server Mobile Services does not need a schema  no need to create columns in the table
  • 36. Azure Mobile Service Backend for app in the cloud Get URL and application key
  • 37. Add Sync Code Sync triggered by action bar button
  • 38. Check Result Run the app and check result of sync in Windows Azure SQL Database
  • 40. Summary  Great to bring existing C# knowledge to mobile platforms Existing business logic C# code might be reused Write once run anywhere is true for most business logic code  You still have to learn and understand the platform Activities, Intents, Services, Adapters, Android SDK, etc.  No or little code sharing for UI markup/code Can be maximized using MVVM approach
  • 41. Saves the day. BASTA 2013 – C# Workshop F&A Rainer Stropek software architects gmbh rainer@timecockpit.com http://www.timecockpit.com @rstropek Danke für euer Kommen Mail Web Twitter