1. So You Want to Develop
on Android...
Timothy Lim @thewheat
thewheatfield.org /cornergeeks.com
Downloads:
http://tiny.cc/googleiobn
http://db.tt/kS08Pb6s
2. Overview
● apk = exe / dmg / tar.gz
○ We're pirates!
○ Portable & Transferable
●
●
●
● Permissions
○ Don't freak out the user
○ AndroidManifest.xml
3. Overview
HC/ICS emulators scare me
○ Get an Android device & download USB drivers now
http://developer.android.com/tools/extras/oem-usb.html
●
● So many pixels
○ so many platforms
○ so little time
■ Android 2.2
■ HVGA (480x320)
●
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 don't need no Java! (ok maybe a little)
●
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. PhoneGap Sample - Starting Up
assets/www/index.html
Start something when app is loaded
●
<body onload="onLoad()">
-------------------------------------------------------
function onLoad() {
document.addEventListener("deviceready",
onDeviceReady, false);
}
function onDeviceReady(){
initializeMapICentre();
}
●
8. PhoneGap Sample - jQuery
jQuery 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. PhoneGap Sample - AJAX
// retrieve a webpage via PhoneGap
// not really applicable in normal AJAX calls, i.e. can't test in browser
●
$.get(url, function(data){
// data contains page source code
// process via Javascript
var pos_end = data.indexOf(" like");
var pos_start = data.indexOf(">", pos_end - 10);
$("#divContent").text(data.substring(pos_start+1, pos_end) + " likes");
});
● Your browser's BFFs
○ View source
○ Right click > Inspect element
(Chrome/Chromium/Firefox with Firebug/Opera)
○ WYSI(NOT)WYG
■ Facebook / Twitter
10. PhoneGap Sample - jQuery
$.get(url, function(data){
// process via jQuery
var 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
● Don't waste time. Ask help / find alternative
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