Android Plugins
Agenda <ul><li>What makes me qualified to talk about this? </li></ul><ul><li>What is Phone Gap ? </li></ul><ul><li>How do ...
What makes me qualified to talk about this?
Currently top committer to PhoneGap-Android
Authored Various Plugins <ul><li>BarcodeScanner  – scans and encodes bar codes. </li></ul><ul><li>ChildBrowser  – open rem...
What is Phone Gap ?
Phone Gap  is... <ul><li>a tool for building mobile applications using web technologies. </li></ul><ul><li>HTML for layout...
 
How do I extend Phone Gap ?
Plugins to the rescue <ul><li>Clean  from an engineering perspective.  </li></ul><ul><li>Lighter  builds possible.  </li><...
Plugin Native Interface
Plugin JavaScript Interface
Basic Example <ul><li>Create you JavaScript </li></ul>
Basic Example <ul><li>Create you Java Code </li></ul>
Basic Example <ul><li>Add plugin to config file res/xml/plugins.xml </li></ul>< plugin   name =&quot; HelloWorld &quot;  v...
Callbacks <ul><li>In your PhoneGap.exec() the first two parameters are the success and failure callbacks.  </li></ul><ul><...
Keep Alive <ul><li>But what if you want to call your success call back multiple times. </li></ul><ul><li>Save the callback...
Web Intent Plugin <ul><li>Sometimes it isn't necessary to create a brand new plugin if you just want to call an intent. </...
<ul><li>Questions? </li></ul>
Let's Hack!
Resources <ul><li>More Info  –  http://www.phonegap.com/ </li></ul><ul><li>Getting Started  – http://www.phonegap.com/star...
Upcoming SlideShare
Loading in...5
×

Phone gap android plugins

6,975

Published on

Ottawa Android presentation Oct 8th.

Published in: Technology, Art & Photos
2 Comments
6 Likes
Statistics
Notes
No Downloads
Views
Total Views
6,975
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
78
Comments
2
Likes
6
Embeds 0
No embeds

No notes for slide

Phone gap android plugins

  1. 1. Android Plugins
  2. 2. Agenda <ul><li>What makes me qualified to talk about this? </li></ul><ul><li>What is Phone Gap ? </li></ul><ul><li>How do I extend Phone Gap ? </li></ul><ul><li>Questions? </li></ul><ul><li>Let's Hack! </li></ul>
  3. 3. What makes me qualified to talk about this?
  4. 4. Currently top committer to PhoneGap-Android
  5. 5. Authored Various Plugins <ul><li>BarcodeScanner – scans and encodes bar codes. </li></ul><ul><li>ChildBrowser – open remote web pages without interrupting your app. </li></ul><ul><li>FTPClient – pretty obvious </li></ul><ul><li>TTS – Text to Speech service </li></ul><ul><li>VideoPlayer – works around broken <video/> tag in WebView </li></ul>
  6. 6. What is Phone Gap ?
  7. 7. Phone Gap is... <ul><li>a tool for building mobile applications using web technologies. </li></ul><ul><li>HTML for layout </li></ul><ul><li>JavaScript to access device functionality </li></ul><ul><li>CSS for rich look and feel </li></ul><ul><li>Standards based </li></ul>
  8. 9. How do I extend Phone Gap ?
  9. 10. Plugins to the rescue <ul><li>Clean from an engineering perspective. </li></ul><ul><li>Lighter builds possible. </li></ul><ul><li>Adaptable for 3rd party extensions. </li></ul><ul><li>Portable to new platforms. </li></ul><ul><li>Secure only use what you need. </li></ul>
  10. 11. Plugin Native Interface
  11. 12. Plugin JavaScript Interface
  12. 13. Basic Example <ul><li>Create you JavaScript </li></ul>
  13. 14. Basic Example <ul><li>Create you Java Code </li></ul>
  14. 15. Basic Example <ul><li>Add plugin to config file res/xml/plugins.xml </li></ul>< plugin name =&quot; HelloWorld &quot; value =&quot; com.phonegap.plugins.hello.HelloWorld &quot; /> <ul><li>Call it from JavaScript: window . plugins . helloWorld . sayHi ( 'Hi Android' ); </li></ul>
  15. 16. Callbacks <ul><li>In your PhoneGap.exec() the first two parameters are the success and failure callbacks. </li></ul><ul><li>The success call back is executed when your Java code returns a status of PluginResult.Status. OK </li></ul><ul><li>The failure call back is executed when you return: </li></ul><ul><ul><li>PluginResult.Status .CLASS_NOT_FOUND_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status . ILLEGAL_ACCESS_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status .INSTANTIATION_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status .MALFORMED_URL_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status . IO_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status .INVALID_ACTION </li></ul></ul><ul><ul><li>PluginResult.Status .JSON_EXCEPTION </li></ul></ul><ul><ul><li>PluginResult.Status .ERROR </li></ul></ul>
  16. 17. Keep Alive <ul><li>But what if you want to call your success call back multiple times. </li></ul><ul><li>Save the callback ID </li></ul><ul><li>this .c allbackId = callbackId; </li></ul><ul><li>Use the keepAlive parameter. </li></ul><ul><li>PluginResult result = new PluginResult(PluginResult.Status. NO_RESULT ); result.setKeepCallback( true ); </li></ul><ul><li>Call the success function whenever you have a new result: </li></ul><ul><li>PluginResult result = new PluginResult(PluginResult.Status. OK , info); </li></ul><ul><li>result.setKeepCallback(true); </li></ul><ul><li>this .success(result, this .c allbackId ); </li></ul>
  17. 18. Web Intent Plugin <ul><li>Sometimes it isn't necessary to create a brand new plugin if you just want to call an intent. </li></ul><ul><li>The solution is Boris Smus' WebIntent Plugin. </li></ul><ul><li>window.plugins.webintent.startActivity(extras, success, fail); </li></ul><ul><li>Send an email for instance: </li></ul><ul><li>window.plugins.webintent.startActivity({ </li></ul><ul><li>action: WebIntent.ACTION_SEND, </li></ul><ul><li>type: 'text/plain', </li></ul><ul><li>extras: extras </li></ul><ul><li>}, function() {}, </li></ul><ul><li>function() { </li></ul><ul><li>alert('Failed to send email via Android Intent'); </li></ul><ul><li>} </li></ul><ul><li>); </li></ul>
  18. 19. <ul><li>Questions? </li></ul>
  19. 20. Let's Hack!
  20. 21. Resources <ul><li>More Info – http://www.phonegap.com/ </li></ul><ul><li>Getting Started – http://www.phonegap.com/start </li></ul><ul><li>Mailing List / Google Group – http://groups.google.com/group/phonegap </li></ul><ul><li>API Documentation – http://docs.phonegap.com/ </li></ul><ul><li>Wiki – http://wiki.phonegap.com/w/page/16494772/FrontPage </li></ul><ul><li>CODE – http://github.com/phonegap </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×