SlideShare a Scribd company logo
1 of 20
Download to read offline
Ryan Paul
Developer Evangelist
Xamarin
Mail: ryan@xamarin.com
Twitter: @segphault
Building Hybrid Apps
with Xamarin
NATIVE
VERSUS
HTML5?
It’s not a battle to the death.
Reframing the Debate
It’s about using the right tool for the right job.
Advantages of HTML
Express high-level design concepts with declarative markup
Tons of control over presentation: gradients, shadows,
transparency, animation, rich text
Vendor-neutral open standards enable widespread support and
broad portability
Easy to learn and use—can tap into existing expertise
Ease of rapid prototyping lets you get great stuff working quickly
•
•
•
•
•
Disadvantages of HTML
Lack of consistency between rendering engines
Difficult to get optimal performance and acceptably responsive user
interface
Lack of native controls means that you can’t match the platform’s
native look and feel
No access to platform-specific functionality
HTML rendering engines confine you to a lowest-common-
denominator user experience
•
•
•
•
•
Give them the high-quality native app that they deserve!
Your users expect better.
This is kind of what it’s like for users when a
mobile developer ships a non-native app:
Advantages of Native Development
Access the full range of rich device capabilities and
native platform features
Native controls supplied by the platform are tailored
for ideal performance and benefit from platform-level
optimizations and hardware acceleration
Native code gives you a lot more room for optimization
and parallelization
Perfectly conform with the standard user interface
conventions of the underlying platform
•
•
•
•
Hybrid Advantages
Decide which parts of your app
should be HTML or native
Expose device capabilities and native
platform features to your HTML
content
Easy to transition to fully native
application if you reach the limits of
HTML
•
•
•
Share code across platforms: C#, JavaScript, and HTML.
Use platform-specific APIs and native user interface controls.
Xamarin for Hybrids
Displaying HTML Content in Native Apps
An HTML view can be a highly effective tool for displaying
rich content in native applications
Ideal for use in scenarios where you need complex formatting
and want to intersperse graphics
With responsive design techniques, content can be made to
seamlessly adapt to different screen sizes and orientations
Razor templating engine can be used in native applications to
generate HTML content that incorporates relevant data
•
•
•
•
A simple Pokédex application built with Xamarin.iOS
DEMO: Razordex
Implementing Razordex
public class Pokemon
{
public int number { get; set; }
public string name { get; set; }
public string primary_type { get; set; }
public string secondary_type { get; set; }
public string biography { get; set; }
public string primary_ability { get; set; }
public string secondary_ability { get; set; }
}
...
var template = new PokemonHTMLView () { Model = detailItem };
webDetailView.LoadHtmlString (
template.GenerateString (),
NSBundle.MainBundle.BundleUrl);
@model Pokemon
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<div class="header">Type</div>
<table class="data">
<tr>
<td><b>Primary:</b></td>
<td>@Model.primary_type</td>
</tr>
<tr>
<td><b>Secondary:</b></td>
<td>@Model.secondary_type</td>
</tr>
</table>
</div>
...
No ferrets were harmed in the making
of this app.
There are several ways to enable interaction between the native part
of your application and the HTML view.
Hybrid Communication Techniques
Expose a C# function to JavaScript
<div onclick="Foo.bar('This is a test!')" class="button">Test</div>
class Foo : Java.Lang.Object
{
...
[Export ("bar")]
public void Bar (Java.Lang.String message)
{
Toast.MakeText (context,
"Message called from JavaScript: " + message, ToastLength.Short).Show ();
}
}
...
WebView web = FindViewById<WebView> (Resource.Id.myWeb);
web.Settings.JavaScriptEnabled = true;
web.AddJavascriptInterface (new Foo (this), "Foo");
web.LoadUrl("file:///android_asset/main.html");
Intercept a Link Handler
<a href="message:This is a test!">Test</a>
private class CustomWebViewClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading (WebView view, string url)
{
if (url.StartsWith ("message:")) {
var message = Uri.UnescapeDataString(url.Split(new char[] { ':' }, 2)[1]);
Toast.MakeText (view.Context,
"Message called from JavaScript: " + message, ToastLength.Short).Show ();
return true;
} else return false;
}
}
...
WebView web = FindViewById<WebView> (Resource.Id.myWeb);
web.SetWebViewClient (new CustomWebViewClient ());
web.Settings.JavaScriptEnabled = true;
web.LoadUrl("file:///android_asset/main.html");
Call JavaScript from C#
WebView web = FindViewById<WebView> (Resource.Id.myWeb);
web.Settings.JavaScriptEnabled = true;
web.LoadUrl("file:///android_asset/main.html");
Button button = FindViewById<Button> (Resource.Id.button1);
button.Click += (object sender, EventArgs e) => {
web.LoadUrl("javascript:document.getElementById('button').innerHTML = 'Hello!'");
};
Q&A
THANK YOU

More Related Content

What's hot

Cross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and XamarinCross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and XamarinKMS Technology
 
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful ServicesHitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful ServicesHeather Downing
 
Smaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giantSmaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giantHeather Downing
 
Cross Platform Development with Xamarin
Cross Platform Development with XamarinCross Platform Development with Xamarin
Cross Platform Development with Xamarinbryan costanich
 
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
 
Highlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceHighlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceChristopher Miller
 
Xamarin 3 hieu 19-06
Xamarin 3   hieu 19-06Xamarin 3   hieu 19-06
Xamarin 3 hieu 19-06Nguyen Hieu
 
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin
 
Xamarin Cross-Platform with Xamarin.Form, MvvmCross
Xamarin Cross-Platform with Xamarin.Form, MvvmCrossXamarin Cross-Platform with Xamarin.Form, MvvmCross
Xamarin Cross-Platform with Xamarin.Form, MvvmCrossTri Nguyen
 
Developing and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioDeveloping and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioXamarin
 
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsOptimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsJames Montemagno
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinJoe Koletar
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
Cross platform mobile development with xamarin and office 365
Cross platform mobile development with xamarin and office 365Cross platform mobile development with xamarin and office 365
Cross platform mobile development with xamarin and office 365SoHo Dragon
 

What's hot (20)

Cross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and XamarinCross Platform Mobile Development with C# and Xamarin
Cross Platform Mobile Development with C# and Xamarin
 
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful ServicesHitchhicker's Guide to Using Xamarin Forms with RESTful Services
Hitchhicker's Guide to Using Xamarin Forms with RESTful Services
 
Xamarin
XamarinXamarin
Xamarin
 
Smaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giantSmaller Not Taller: Defeating the mobile application architecture giant
Smaller Not Taller: Defeating the mobile application architecture giant
 
Cross Platform Development with Xamarin
Cross Platform Development with XamarinCross Platform Development with Xamarin
Cross Platform Development 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
 
Highlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conferenceHighlights from the Xamarin Evolve 2016 conference
Highlights from the Xamarin Evolve 2016 conference
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
Cross Platform Mobile Development
Cross Platform Mobile DevelopmentCross Platform Mobile Development
Cross Platform Mobile Development
 
Xamarin 3 hieu 19-06
Xamarin 3   hieu 19-06Xamarin 3   hieu 19-06
Xamarin 3 hieu 19-06
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
 
Xamarin Cross-Platform with Xamarin.Form, MvvmCross
Xamarin Cross-Platform with Xamarin.Form, MvvmCrossXamarin Cross-Platform with Xamarin.Form, MvvmCross
Xamarin Cross-Platform with Xamarin.Form, MvvmCross
 
Developing and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin StudioDeveloping and Designing Native Mobile Apps in Xamarin Studio
Developing and Designing Native Mobile Apps in Xamarin Studio
 
Introduction to Xamarin
Introduction to XamarinIntroduction to Xamarin
Introduction to Xamarin
 
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP AppsOptimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
 
Cross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with XamarinCross Platform Mobile Development with Xamarin
Cross Platform Mobile Development with Xamarin
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
Cross platform mobile development with xamarin and office 365
Cross platform mobile development with xamarin and office 365Cross platform mobile development with xamarin and office 365
Cross platform mobile development with xamarin and office 365
 
Xamarin介紹
Xamarin介紹Xamarin介紹
Xamarin介紹
 

Similar to Building hybrid apps with Xamarin, Ryan Paul

App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles xamarinMohit Chhabra
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinPranav Ainavolu
 
SharePoint Mobile App Development with Xmarin
SharePoint Mobile App Development with XmarinSharePoint Mobile App Development with Xmarin
SharePoint Mobile App Development with XmarinHector Luciano Jr
 
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloperphp2ranjan
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Roy Gilad
 
Mobile Tech Strategies - 4 Sept 2016 V6
Mobile Tech Strategies - 4 Sept 2016 V6Mobile Tech Strategies - 4 Sept 2016 V6
Mobile Tech Strategies - 4 Sept 2016 V6Ian Morrison
 
ucla_curriculum_overview_12116
ucla_curriculum_overview_12116ucla_curriculum_overview_12116
ucla_curriculum_overview_12116John Nguyen
 
Writing Code to Work Against any Salesforce Object
Writing Code to Work Against any Salesforce ObjectWriting Code to Work Against any Salesforce Object
Writing Code to Work Against any Salesforce ObjectSalesforce Developers
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replitmatiasfund
 
How to Hire a .NET developer Step-By-Step Guide.pdf
How to Hire a .NET developer Step-By-Step Guide.pdfHow to Hire a .NET developer Step-By-Step Guide.pdf
How to Hire a .NET developer Step-By-Step Guide.pdfJane Brewer
 
Mobile web or native app
Mobile web or native appMobile web or native app
Mobile web or native appMike Takahashi
 
HTML5: Next Generation Web Development
HTML5: Next Generation Web DevelopmentHTML5: Next Generation Web Development
HTML5: Next Generation Web DevelopmentDipesh Mukerji
 

Similar to Building hybrid apps with Xamarin, Ryan Paul (20)

App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles xamarin
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with Xamarin
 
SharePoint Mobile App Development with Xmarin
SharePoint Mobile App Development with XmarinSharePoint Mobile App Development with Xmarin
SharePoint Mobile App Development with Xmarin
 
tomtaila
tomtailatomtaila
tomtaila
 
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper
2018 p.ranjan.raja msc-13_year_ex_php_webdeveloper
 
DOT NET FULL STACK.pptx
DOT NET FULL STACK.pptxDOT NET FULL STACK.pptx
DOT NET FULL STACK.pptx
 
Sharif
SharifSharif
Sharif
 
Sharif
SharifSharif
Sharif
 
Introduction to xamarin
Introduction to xamarinIntroduction to xamarin
Introduction to xamarin
 
rohit sharma
rohit sharmarohit sharma
rohit sharma
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)
 
Mobile Tech Strategies - 4 Sept 2016 V6
Mobile Tech Strategies - 4 Sept 2016 V6Mobile Tech Strategies - 4 Sept 2016 V6
Mobile Tech Strategies - 4 Sept 2016 V6
 
ucla_curriculum_overview_12116
ucla_curriculum_overview_12116ucla_curriculum_overview_12116
ucla_curriculum_overview_12116
 
Resume ram-krishna
Resume ram-krishnaResume ram-krishna
Resume ram-krishna
 
Writing Code to Work Against any Salesforce Object
Writing Code to Work Against any Salesforce ObjectWriting Code to Work Against any Salesforce Object
Writing Code to Work Against any Salesforce Object
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replit
 
How to Hire a .NET developer Step-By-Step Guide.pdf
How to Hire a .NET developer Step-By-Step Guide.pdfHow to Hire a .NET developer Step-By-Step Guide.pdf
How to Hire a .NET developer Step-By-Step Guide.pdf
 
resume
resumeresume
resume
 
Mobile web or native app
Mobile web or native appMobile web or native app
Mobile web or native app
 
HTML5: Next Generation Web Development
HTML5: Next Generation Web DevelopmentHTML5: Next Generation Web Development
HTML5: Next Generation Web Development
 

More from Xamarin

Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinXamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushXamarin
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureXamarin
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksXamarin
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinXamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningXamarin
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UIXamarin
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesXamarin
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilityXamarin
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeXamarin
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Xamarin
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsXamarin
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureXamarin
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Xamarin
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureXamarin
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Xamarin
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioXamarin
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with XamarinXamarin
 

More from Xamarin (20)

Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 
Building Your First Android App with Xamarin
Building Your First Android App with XamarinBuilding Your First Android App with Xamarin
Building Your First Android App with Xamarin
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

Building hybrid apps with Xamarin, Ryan Paul

  • 1. Ryan Paul Developer Evangelist Xamarin Mail: ryan@xamarin.com Twitter: @segphault Building Hybrid Apps with Xamarin
  • 3. It’s not a battle to the death. Reframing the Debate It’s about using the right tool for the right job.
  • 4. Advantages of HTML Express high-level design concepts with declarative markup Tons of control over presentation: gradients, shadows, transparency, animation, rich text Vendor-neutral open standards enable widespread support and broad portability Easy to learn and use—can tap into existing expertise Ease of rapid prototyping lets you get great stuff working quickly • • • • •
  • 5. Disadvantages of HTML Lack of consistency between rendering engines Difficult to get optimal performance and acceptably responsive user interface Lack of native controls means that you can’t match the platform’s native look and feel No access to platform-specific functionality HTML rendering engines confine you to a lowest-common- denominator user experience • • • • •
  • 6.
  • 7. Give them the high-quality native app that they deserve! Your users expect better. This is kind of what it’s like for users when a mobile developer ships a non-native app:
  • 8. Advantages of Native Development Access the full range of rich device capabilities and native platform features Native controls supplied by the platform are tailored for ideal performance and benefit from platform-level optimizations and hardware acceleration Native code gives you a lot more room for optimization and parallelization Perfectly conform with the standard user interface conventions of the underlying platform • • • •
  • 9. Hybrid Advantages Decide which parts of your app should be HTML or native Expose device capabilities and native platform features to your HTML content Easy to transition to fully native application if you reach the limits of HTML • • •
  • 10. Share code across platforms: C#, JavaScript, and HTML. Use platform-specific APIs and native user interface controls. Xamarin for Hybrids
  • 11. Displaying HTML Content in Native Apps An HTML view can be a highly effective tool for displaying rich content in native applications Ideal for use in scenarios where you need complex formatting and want to intersperse graphics With responsive design techniques, content can be made to seamlessly adapt to different screen sizes and orientations Razor templating engine can be used in native applications to generate HTML content that incorporates relevant data • • • •
  • 12. A simple Pokédex application built with Xamarin.iOS DEMO: Razordex
  • 13. Implementing Razordex public class Pokemon { public int number { get; set; } public string name { get; set; } public string primary_type { get; set; } public string secondary_type { get; set; } public string biography { get; set; } public string primary_ability { get; set; } public string secondary_ability { get; set; } } ... var template = new PokemonHTMLView () { Model = detailItem }; webDetailView.LoadHtmlString ( template.GenerateString (), NSBundle.MainBundle.BundleUrl); @model Pokemon <html> <head> <link type="text/css" rel="stylesheet" href="style.css" /> </head> <body> <div class="container"> <div class="header">Type</div> <table class="data"> <tr> <td><b>Primary:</b></td> <td>@Model.primary_type</td> </tr> <tr> <td><b>Secondary:</b></td> <td>@Model.secondary_type</td> </tr> </table> </div> ...
  • 14. No ferrets were harmed in the making of this app.
  • 15. There are several ways to enable interaction between the native part of your application and the HTML view. Hybrid Communication Techniques
  • 16. Expose a C# function to JavaScript <div onclick="Foo.bar('This is a test!')" class="button">Test</div> class Foo : Java.Lang.Object { ... [Export ("bar")] public void Bar (Java.Lang.String message) { Toast.MakeText (context, "Message called from JavaScript: " + message, ToastLength.Short).Show (); } } ... WebView web = FindViewById<WebView> (Resource.Id.myWeb); web.Settings.JavaScriptEnabled = true; web.AddJavascriptInterface (new Foo (this), "Foo"); web.LoadUrl("file:///android_asset/main.html");
  • 17. Intercept a Link Handler <a href="message:This is a test!">Test</a> private class CustomWebViewClient : WebViewClient { public override bool ShouldOverrideUrlLoading (WebView view, string url) { if (url.StartsWith ("message:")) { var message = Uri.UnescapeDataString(url.Split(new char[] { ':' }, 2)[1]); Toast.MakeText (view.Context, "Message called from JavaScript: " + message, ToastLength.Short).Show (); return true; } else return false; } } ... WebView web = FindViewById<WebView> (Resource.Id.myWeb); web.SetWebViewClient (new CustomWebViewClient ()); web.Settings.JavaScriptEnabled = true; web.LoadUrl("file:///android_asset/main.html");
  • 18. Call JavaScript from C# WebView web = FindViewById<WebView> (Resource.Id.myWeb); web.Settings.JavaScriptEnabled = true; web.LoadUrl("file:///android_asset/main.html"); Button button = FindViewById<Button> (Resource.Id.button1); button.Click += (object sender, EventArgs e) => { web.LoadUrl("javascript:document.getElementById('button').innerHTML = 'Hello!'"); };
  • 19. Q&A