Your SlideShare is downloading. ×
Phone gap android plugins
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Phone gap android plugins

6,868
views

Published on

Ottawa Android presentation Oct 8th.

Ottawa Android presentation Oct 8th.

Published in: Technology, Art & Photos

2 Comments
6 Likes
Statistics
Notes
No Downloads
Views
Total Views
6,868
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
73
Comments
2
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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