How To Hybrid 
Custom HTML5-Native Bridge for 
Android 
MICHAEL HANTLER 
ANDROIDDEV101.COM
PhoneGap (Cordova) framework 
The open source framework we all 
know and love uses a similar 
technology in order to transmit 
requests over the HTML5-Java Bridge 
(JavaScript prompt boxes)
If We Build It…They will Code 
Java
It’s All About the WebView Baby 
Similar to the Cordova(PhoneGap) implementation we will 
utilize built-in components of the Android WebView. This 
functionality will give us two way communication between 
our Java code and our HTML5(JavaScript) code.
JavaScript to Java 
public void addJavascriptInterface (Object object, String name) 
class JsObject { 
@JavascriptInterface 
public String toString() { return "injectedObject"; } 
} 
webView.addJavascriptInterface(new JsObject(), "injectedObject"); 
webView.loadData("", "text/html", null); 
webView.loadUrl("javascript:alert(injectedObject.toString())");
WebView Exploits 
AVG: Analyzing an Android 
WebView exploit by Elad 
Shapira 
MWR InfoSecurity: WebView 
addJavascriptInterface Remote 
Code Execution 
Trigger.io: Why Trigger.io 
doesn’t use PhoneGap – 5x 
faster native bridge
Java to JavaScript 
public void loadUrl (String url) 
class JsObject { 
@JavascriptInterface 
public String toString() { return "injectedObject"; } 
} 
webView.addJavascriptInterface(new JsObject(), "injectedObject"); 
webView.loadData("", "text/html", null); 
webView.loadUrl("javascript:alert(injectedObject.toString())");
Examples on GitHub 
All example code can be found on Github at https://github.com/mhant/DroidConTLV2014
Basic Bridge example
Example: Ads
Example: Drawer
Example: Login
Shout Outs 
Delivering the highest quality mobile app and web app 
development. Previous clients include Caesars Interactive 
Entertainment, YMCA related firms, and a wide assortment of 
breakthrough startups.

More Related Content

PPTX
MVC3 Development with visual studio 2010
PPTX
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
DOCX
Different way to share data between controllers in angular js
ODP
Introduction to Knockout Js
PPT
Pdm Common Framework Version 0.3
PPT
JAVA SCRIPT
DOCX
AngularJS
PPTX
Java Script - A New Look
MVC3 Development with visual studio 2010
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Different way to share data between controllers in angular js
Introduction to Knockout Js
Pdm Common Framework Version 0.3
JAVA SCRIPT
AngularJS
Java Script - A New Look

What's hot (20)

PPTX
React JS .NET
DOCX
Adding a view
PPTX
ASP .Net MVC 5
PDF
PPTX
Introduction to Angular JS
PPTX
Visual Studio 2010 Ultimate Architecture Experience : Toronto Code Camp 2010 ...
PPTX
Valentine with AngularJS
PPTX
reactJS
PPTX
React js for beginners
PPTX
Angular Data Binding
PPT
Introduction to Vaadin
PDF
Huge web apps web expo 2013
PPT
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
PPTX
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
PPTX
angularJS Practicle Explanation
PPTX
React workshop presentation
PPTX
Comparing Angular and React JS for SPAs
PDF
OSGi and Spring Data for simple (Web) Application Development
PDF
Jinal desai .net
React JS .NET
Adding a view
ASP .Net MVC 5
Introduction to Angular JS
Visual Studio 2010 Ultimate Architecture Experience : Toronto Code Camp 2010 ...
Valentine with AngularJS
reactJS
React js for beginners
Angular Data Binding
Introduction to Vaadin
Huge web apps web expo 2013
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
angularJS Practicle Explanation
React workshop presentation
Comparing Angular and React JS for SPAs
OSGi and Spring Data for simple (Web) Application Development
Jinal desai .net
Ad

Similar to Custom HTML5-Native Bridge for Android (20)

PDF
Hybrid apps - Your own mini Cordova
PDF
Hybrid apps: Java conversing with JavaScript
PDF
Gdg dev fest hybrid apps your own mini-cordova
PDF
Vaadin & Web Components
PDF
Google Web Toolkit
PDF
Vaadin 7 CN
PDF
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
PPTX
Android App Development using HTML5 Technology
PDF
The art of Building Bridges for Android Hybrid Apps
PDF
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
PPTX
Introduction to Apache Cordova (Phonegap)
PDF
The WebView Role in Hybrid Applications
PPTX
React native by example by Vadim Ruban
PPT
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
Hybrid App using WordPress
PDF
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
PDF
Vaadin Components
PDF
125 고성능 web view-deview 2013 발표 자료_공유용
PDF
Beyond HTML: Tools for Building Web 2.0 Apps
Hybrid apps - Your own mini Cordova
Hybrid apps: Java conversing with JavaScript
Gdg dev fest hybrid apps your own mini-cordova
Vaadin & Web Components
Google Web Toolkit
Vaadin 7 CN
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Android App Development using HTML5 Technology
The art of Building Bridges for Android Hybrid Apps
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
Introduction to Apache Cordova (Phonegap)
The WebView Role in Hybrid Applications
React native by example by Vadim Ruban
Moving to the Client - JavaFX and HTML5 (PowerPoint Version)
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
Hybrid App using WordPress
HTML alchemy: the secrets of mixing JavaScript and Java EE - Matthias Wessendorf
Vaadin Components
125 고성능 web view-deview 2013 발표 자료_공유용
Beyond HTML: Tools for Building Web 2.0 Apps
Ad

Recently uploaded (10)

DOC
办Rice毕业证学历认证,哈金森社区学院毕业证留学本科毕业证
PDF
Empowerment technologies presentation that helps student
PDF
Top 10 Platforms for Securely Buying Verified Cash App Accounts.pdf
PPTX
BSNL Consumer Workshop ppt.pptx Telangana
PDF
mao_guerrilla_warfare,mao zedongun gerilla savaşı üzerine yazısı
DOC
哪里买SBU毕业证学历认证,卡罗尔大学毕业证留学学历
PPTX
mathematucicsSolving_Equationspptegypt.pptx
PPTX
The-Literary-Elements in non fiction creative
PDF
Facial Recognition System Singapore_ 1 SGD Per Month.pdf
DOC
DU毕业证学历认证,伯克利音乐学院毕业证留学本科毕业证
办Rice毕业证学历认证,哈金森社区学院毕业证留学本科毕业证
Empowerment technologies presentation that helps student
Top 10 Platforms for Securely Buying Verified Cash App Accounts.pdf
BSNL Consumer Workshop ppt.pptx Telangana
mao_guerrilla_warfare,mao zedongun gerilla savaşı üzerine yazısı
哪里买SBU毕业证学历认证,卡罗尔大学毕业证留学学历
mathematucicsSolving_Equationspptegypt.pptx
The-Literary-Elements in non fiction creative
Facial Recognition System Singapore_ 1 SGD Per Month.pdf
DU毕业证学历认证,伯克利音乐学院毕业证留学本科毕业证

Custom HTML5-Native Bridge for Android

  • 1. How To Hybrid Custom HTML5-Native Bridge for Android MICHAEL HANTLER ANDROIDDEV101.COM
  • 2. PhoneGap (Cordova) framework The open source framework we all know and love uses a similar technology in order to transmit requests over the HTML5-Java Bridge (JavaScript prompt boxes)
  • 3. If We Build It…They will Code Java
  • 4. It’s All About the WebView Baby Similar to the Cordova(PhoneGap) implementation we will utilize built-in components of the Android WebView. This functionality will give us two way communication between our Java code and our HTML5(JavaScript) code.
  • 5. JavaScript to Java public void addJavascriptInterface (Object object, String name) class JsObject { @JavascriptInterface public String toString() { return "injectedObject"; } } webView.addJavascriptInterface(new JsObject(), "injectedObject"); webView.loadData("", "text/html", null); webView.loadUrl("javascript:alert(injectedObject.toString())");
  • 6. WebView Exploits AVG: Analyzing an Android WebView exploit by Elad Shapira MWR InfoSecurity: WebView addJavascriptInterface Remote Code Execution Trigger.io: Why Trigger.io doesn’t use PhoneGap – 5x faster native bridge
  • 7. Java to JavaScript public void loadUrl (String url) class JsObject { @JavascriptInterface public String toString() { return "injectedObject"; } } webView.addJavascriptInterface(new JsObject(), "injectedObject"); webView.loadData("", "text/html", null); webView.loadUrl("javascript:alert(injectedObject.toString())");
  • 8. Examples on GitHub All example code can be found on Github at https://github.com/mhant/DroidConTLV2014
  • 13. Shout Outs Delivering the highest quality mobile app and web app development. Previous clients include Caesars Interactive Entertainment, YMCA related firms, and a wide assortment of breakthrough startups.