Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source)...

25
 Android Michael Greifeneder Image source: Android homepage

Transcript of Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source)...

Page 1: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Android

Michael Greifeneder

Image source: Android homepage

Page 2: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Inhalt

● Overwiew● Hardware● Software

● Development● Tools● Basics● Debugging/Emulator● Location

● Demo

Page 3: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Android And Me

● Why I like Android● Blend of Linux and Java● Open (Source)● Development on Ubuntu :)● USB mass storage● Tethering (USB, Wifi)

● Don't like● Battery life● Default LookNFeel

Page 4: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Hardware

● Typically ARM processors, up to 1 GHz● 256-512 MB RAM, up to 1 GB ROM● Connectivity: GSM/EDGE, UMTS,

Bluetooth, Wi-Fi, and WiMAX.● Cameras, GPS, accelerometers, SD card● Optional

physical keyboard● ~34 devices...

Image sources: Device manufacturer

Page 5: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

3,4

28

13,8

12,3

4,73,1

Forecast 2010 North America

SymbianRIMAppleGoogleMicrosoftPalm

44,3

19,4

15,4

9,6

6,83,70,7

1Q10 Worldwide Sales

SymbianResearch In MotioniPhone OSAndroidMicrosoft Windows MobileLinuxOther OSs

Smartphone Sales Stats● North America

● Source: Canalys● Total: 65 Mio

● Worldwide 1Q10● Source: Gartner● Total: 54 Mio/Q

http://www.gartner.com/it/page.jsp?id=1372013 http://www.gartner.com/it/page.jsp?id=985912

2008 2009 2010

0

2

4

6

8

10

12

14

16

18

Q1 Worldwide

AndroidiPhone

Page 6: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Markets● Google's Android Market (>50.000 Apps)

● 25$ one-time registration● No restrictions

● Alternatives available (android.pdassi.de)● Just click on an .apk file...

http://xkcd.com/662/ Creative Commons Attribution-NonCommercial 2.5 License.

Page 7: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Software● Tweaked Linux kernel (2.6.27-32)

● No X Window System● Dalvik/Java Runtime

● register-based architecture● .dex format● dx tool convert .class files to .dex● Neither AWT, Swing nor JavaME

supported● JIT implementation (Android 2.2)

● Open Source (Apache license)

Page 8: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Architecturehttp://developer.android.com/guide/basics/what-is-android.html

Page 9: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Kernelhttp://android.git.kernel.org/

From Kevin Mcdonagh slides: http://www.scribd.com/doc/31664622/Android-Source-Code-Guided-Tour

Page 10: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Versions

● Cupcake● 1.5 (API 3)

● Donut● 1.6 (API 4)

● Eclair● 2.0 (API 5), 2.0.1 (API 6) +2.1 (API 7)

● FroYo (Frozen Yoghurt)● 2.2 (API 8)

Image source: Android homepage

Page 11: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Development

● Android SDK● → http://developer.android.com/sdk

● Eclipse + Android Development Tools● https://dl-ssl.google.com/android/eclipse/

● Java+XML● C/C++ for NDK

Image source: Self-made screenshots

Page 12: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Toolset

● adb (Android Debug Bridge)● Installing an Application● Copying Files to or from Device/Emulator● Remote Shell

● z.B. Sqlite command-line

● DDMS (Dalvik Debug Monitor Server)● Uses adb● middleman btw. IDE + applications

● logcat

Page 13: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Emulator

● Android Virtual Devices (AVD)● hardware profile● mapping to a system image● dedicated storage area

● Emulator runs AVDs● Emulates: Calls, SMS● Location, Camera● Network-speed

Image source: Self-made screenshots

Page 14: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Widgets● Layout in XML files● Layouts: LinearLayout,

RelativeLayout, FrameLayout, TableLayout,AbsoluteLayout(pfui)

● Basic Widgets: TextView, Button, EditText, ImageView

● DatePicker, TimePicker, Tabs● OptionMenu, ContextMenu● WebView (WebKit)

Image source: Self-made screenshots

Page 15: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

GUI Designer?

● Android Layout Editor in Eclipse● Forget it.

● DroidDraw http://www.droiddraw.org/● Yeah,

but...

Image source: Self-made screenshots

Page 16: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Project Structure

● AndroidManifest.xml● /src● /res

● /layout● /menu● /drawable

● /gen● /values/strings.xml

Page 17: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Security

● User must confirm access● Declare required

permissions inAndroidManifest.xml

● <uses-permission android:name= "android.permission.INTERNET"/>

● <uses-permission android:name= "android.permission. ACCESS_FINE_LOCATION" />

● <uses-permission android:name= "android.permission.CAMERA" />

Image source: http://www.taosoftware.co.jp/en/android/wakeupcallmaker/

Page 18: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Activities <--> Intents

● Activity = One screen● Intents (abstract description of an operation)

● Explicit intents (same app)● Implicit intents (inter App operation)

● Example:● Action: Intent.ACTION_DIAL● Data: ”tel:01567890”

● Intent filters● Declare receiving of intents

Page 19: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Activity

● Methods● onCreate

● setContentView(R.layout.XML_FILE);● findViewById(R.id.ID_IN_LAYOUT);

● onDestroy/onPause/onResume● Call internal activity

● Intent intent = new Intent(this, OtherActivity.class);startActivity(intent); //or startActivityForResult(intent, 1);

Page 20: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

The Mighty List

● android.widget.ListView(ListActivity)

● ListAdapter for data● Indiviual layout for row● ArrayAdapter

one Textview in row● SimpleCursorAdapter

● Maps DB columns to resource ids in row layout

Image source: Self-made screenshots

Page 21: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Services...

● Use case● Background tasks● Long running tasks

● Implement a service● AndroidManiferst.xml

<service android:name=".MyService" />

● onCreate/onStart/onDestroy

● onBind() → return a subclassed Binder that extends Binder and implements custom method:

getService()

Page 22: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Use Service (local)

● Intent intent = new Intent(this. Service.class)

● bindService(intent, serviceConnection, 0);

● interface ServiceConnection {onServiceConnected(Binder binder,...)onServiceDisconnected(...)}

● ((LocalBinder) binder).getService()

Page 23: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Location aware

● LocationManager● getLastKnownLocation● Register for periodic updates● Get notified on location

● Emulator● Open console● telnet localhost <5554?>● geo fix <longitude> <latitude>

Page 24: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Demos

● DB query● Location (Change location in emulator)● Camera

● Intent: android.media.action.IMAGE_CAPTURE is buggy

● http://code.google.com/p/android/issues/detail?id=1480

● Workaround: Do it yourself● Internet

● <uses-permission android:name="android.permission.INTERNET"/>

Page 25: Android - jsug.at · Android And Me Why I like Android Blend of Linux and Java Open (Source) Development on Ubuntu :) USB mass storage Tethering (USB, Wifi) Don't like Battery life

   

Source code:http://github.com/mikegr/aLogMyNight

eBooks:http://commonsware.com/books

??? Questions/Discussion ???