So you want to Develop on Android....

588 views

Published on

Presented at Google I/O Extended Brunei 2012

Published in: Technology
  • Be the first to comment

  • Be the first to like this

So you want to Develop on Android....

  1. 1. So You Want to Developon Android...Timothy Lim @thewheatthewheatfield.org /cornergeeks.comDownloads:http://tiny.cc/googleiobnhttp://db.tt/kS08Pb6s
  2. 2. Overview● apk = exe / dmg / tar.gz○ Were pirates!○ Portable & Transferable●●●● Permissions○ Dont freak out the user○ AndroidManifest.xml
  3. 3. OverviewHC/ICS emulators scare me○ Get an Android device & download USB drivers nowhttp://developer.android.com/tools/extras/oem-usb.html●● So many pixels○ so many platforms○ so little time■ Android 2.2■ HVGA (480x320)●
  4. 4. Get the Tools!● SDK http://developers.android.com○ tools to transfer apk to device○ different Android platforms (1.x,2.x,...) & emulator●● Eclipse http://eclipse.org○ Android Development Tools(ADT) plugin●● PhoneGap http://phonegap.com○ Mobile cross development platform○ i.e. we dont need no Java! (ok maybe a little)●
  5. 5. ● HTML & Javascript based○ Easy & Familiar (if not get familiar)○ Exposes device features via Javascript objects●● Quick design & prototyping○ all in the browser●● Cross platform●● Translatable skills●●Why PhoneGap?
  6. 6. PhoneGap Sample - Starting Upassets/www/index.htmlStart something when app is loaded●<body onload="onLoad()">-------------------------------------------------------function onLoad() {document.addEventListener("deviceready",onDeviceReady, false);}function onDeviceReady(){initializeMapICentre();}●
  7. 7. PhoneGap Sample - Interactivity<a href="#" onclick="mediaPlay()" id="lnk_play"><img id="play" src="images/play.png"></a>-------------------------------------------------------function mediaPlay() {if (!mediaPlaying) {...myAudio = new Media(URL_STREAM); myAudio.play();mediaPlaying = true; ...} else {...myAudio.stop();mediaPlaying = false; ...}}●
  8. 8. PhoneGap Sample - jQueryjQuery makes things easier-- Before jQuery executes -----------------------------------<div id="aLink">hello</div><span class=foo>ice</span><span class=foo>cream</span><span class=foo>sandwich</span>●-- Do jQuery -------------------------------------------------$("#aLink").html("<a href=http://google.com>Google</a>");$(".foo").text("jelly"); $(".foo").eq(1).text("bean");●-- After jQuery executes ------------------------------------<div id="aLink"><a href=http://google.com>Google</a></div><span class=foo>jelly</span><span class=foo>bean</span><span class=foo>jelly</span>
  9. 9. PhoneGap Sample - AJAX// retrieve a webpage via PhoneGap// not really applicable in normal AJAX calls, i.e. cant test in browser●$.get(url, function(data){// data contains page source code// process via Javascriptvar pos_end = data.indexOf(" like");var pos_start = data.indexOf(">", pos_end - 10);$("#divContent").text(data.substring(pos_start+1, pos_end) + " likes");});● Your browsers BFFs○ View source○ Right click > Inspect element(Chrome/Chromium/Firefox with Firebug/Opera)○ WYSI(NOT)WYG■ Facebook / Twitter
  10. 10. PhoneGap Sample - jQuery$.get(url, function(data){// process via jQueryvar element = $("<div></div>").append(data); var msg = ;element.find(".tweets").each(function(i){msg += $(this).find(".tweet-text").text() + "<hr>";});$("#divContent").html(msg);});●● Doh!○ <script> in data messes things up○ White screen of death● Dont waste time. Ask help / find alternative
  11. 11. Hackaway● Make an app!○ No limitations○ Brunei site tie-in possibilities■ Brunei Post Office - online services■ Borneo Bulletin● Possible features:○ Map○ Tweet list○ Facebook● Upload your code to GitHub
  12. 12. ● PhoneGap○ http://phonegap.com● jQuery○ http://jquery.com● Github○ https://github.com○ https://github.com/thewheat/PhoneGapSample● Artwork acknowledgements○ CC-BY-NC: http://phonegap.com/artwork/○ CC: http://android.com/developers/branding.html● Illumination Software Creator○ http://lunduke.com●Links & Stuff
  13. 13. Installing the Tools (Windows)● c:android○ readme.txt● SDK○ install 1..*.exe to c:androidsdk○ unzip updates in c:androidsdk■ 2...*.zip (platformtools)■ 3...*.zip (Android2.2 files)● Eclipse○ unzip 4....*.zip to c:eclipse (EclipseClassic 3.7.2 withupdates)○ install ADT●● PhoneGap○ http://phonegap.com○ unzip to c:android●

×