So you want to Develop on Android....


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 /cornergeeks.comDownloads:
  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 now●● So many pixels○ so many platforms○ so little time■ Android 2.2■ HVGA (480x320)●
  4. 4. Get the Tools!● SDK○ tools to transfer apk to device○ different Android platforms (1.x,2.x,...) & emulator●● Eclipse○ Android Development Tools(ADT) plugin●● PhoneGap○ 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);;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=>Google</a>");$(".foo").text("jelly"); $(".foo").eq(1).text("bean");●-- After jQuery executes ------------------------------------<div id="aLink"><a href=>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○● jQuery○● Github○○● Artwork acknowledgements○ CC-BY-NC:○ CC:● Illumination Software Creator○●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○○ unzip to c:android●