Platforms for Developing Cell
Phone Applications
Fadi Wedyan
Colorado State University
October 23, 2009
Outline
• Why do we need this?
• Android 1.6
–
–
–
–
What is Android?
Features
Installation
Programming in Android
• GUI Design
• Database Applications
• Interprocess Communication
– Publishing an application
– Drawbacks, conclusions
• Symbian OS
– Symbian platforms.
– S60 platform
10/3/2015
2
Why do we need this?
• Dengue Decision Support System (DDSS)
– Collect data from field, sent to station for
processing.
• Current proposal
– Use an application on a cell phone to collect data.
• Direct connection
• Periodic updates
10/3/2015
3
What is Android?
• A platform for cell phones that Includes an
operating system, middleware and key
applications.
• Linux version 2.6 kernel.
• The Android SDK is a framework developing
Java applications on cell phones.
10/3/2015
4
Features
•
•
•
•
•
•
•
•
•
Dalvik virtual machine: optimized for mobile devices
Integrated browser: based on the open source WebKit engine
Optimized graphics: 2D and 3D graphics library
SQLite: a RDBM.
Media support. MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF
GSM Telephony (hardware dependent)
Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
Camera, GPS, compass, and accelerometer (hardware dependent)
Development environment: device emulator, tools for debugging,
memory and performance profiling, and a plugin for the Eclipse IDE
10/3/2015
5
Application Development Features
•
•
•
•
Linux, Windows, Mac.
Android Development Tools (ADT) plugin Eclipse IDE.
Good documentation.
Rich GUI design
– Programmatically
– An XML layout files.
• Remote procedure calls (RPC)
– Using Android Interface Definition Language (AIDL).
• Emulator
– Android Virtual Device (AVD) Configuration.
10/3/2015
6
Application Development Features
[Contd.]
• SDK Add-Ons: Google APIs which Includes the
com.google.android.maps external library.
• A framework for writing Android test cases
and suites.
10/3/2015
7
Installing Android
• http://developer.android.com/index.html
• Install Android SDK.
– Four versions available (1.0, 1.1, 1.5, 1.6), download either
1.5, 1.6
• Install the ADT Plugin for Eclipse (Optional)
– Eclipse 3.4 (Ganymede) or 3.5 (Galileo).
– Help-> Software Updates (Install New Software)->add the
link:
• https://dl-ssl.google.com/android/eclipse/
– Modify Eclipse preferences to point to the Android SDK
directory.
• Window > Preferences..., Select Android from panel, browse for
the Android SDK directory.
10/3/2015
8
Creating an Android Application
1. Create Android Virtual Device (AVD). A
configurations of emulator options for
modeling an actual device.
– Run the command:
•
android create avd --target --name my_avd
Target can be (1,2,3,4).
2. Create a New Android Project
– Check “with activity” if you want to get default
activity.
10/3/2015
9
Programming In Android
• An android program consists of four types of
components:
– Activities.
– Services.
– Broadcast receivers.
– Content providers.
10/3/2015
10
Activities
• Each activity is given a default window to draw
in.
• A GUI for a well-defined action (e.g., a group of
checkboxes to select attributes).
• Like forms in visual languages.
• Extend the Activity base class
10/3/2015
11
Services
• Runs in the background for an indefinite
period of time
– e.g., play background music, fetch data over the
network, or calculate something and provide
result to activities.
• Extend the Service base class.
10/3/2015
12
Broadcast Receivers
• Receive and react to broadcast
announcements .
– broadcasts originate from the system or other
applications.
– e.g., the timezone has changed, the battery is low,
the user changed a language preference.
• Active only while responding to a broadcast
message.
• Extend the BroadcastReceiver base class.
10/3/2015
13
Messages
• Intents: activities, services, and broadcast
receivers — are activated by asynchronous
messages called intents.
10/3/2015
14
GUI Design
• Built using View and ViewGroup objects
• The View class serves as the base for
subclasses called "widgets," which offer fully
implemented UI objects (e.g., text fields,
checkboxes, buttons, …).
• The ViewGroup class serves as the base for
subclasses called "layouts," which offer
different kinds of layout architecture, like
linear, tabular and relative.
10/3/2015
15
GUI Design [Contd.]
• Activity's UI is defined using a
hierarchy of View and ViewGroup
nodes.
• Activity must call the
setContentView() method and pass
a reference to the root node
object.
• Android parses the tree in-order,
starting from the top of the
hierarchy, instantiating the Views
and adding them to their parent.
• View hierarchy is defined in an
XML layout file.
10/3/2015
A sample View Hierarchy
of an activity UI.
16
UI Events
• Two Options:
1. Define an event listener and register it with the
View.
•
•
•
Most common for widgets.
The View class contains a collection of nested interfaces
named On<something>Listener, each with a callback
method called On<something>().
Implement the needed On<something>Listener, register it
to the View with method setOn<something>Listener().
2. Override an existing callback method for the View
•
10/3/2015
Used for user-defined View class and want to listen for
specific events that occur within it.
17
Content providers
• Make a specific set of the application's data
available to other applications.
• Extends the ContentProvider base class.
• Applications use a ContentResolver object to
communicate with a content provider.
• Active only while responding to a request
from a ContentResolver.
10/3/2015
18
Building a Content Provider
1. Plan your database, URIs, column names, and
so on.
2. Extend the abstract class ContentProvider
3. Implement these methods: query, insert,
update, delete, and getType
4. Register the provider in the manifest file.
10/3/2015
19
Planning Database
• Content providers expose their data through a URI
(Uniform Resource Identifier), similar to the way a web
site uses URLs.
– Two to Four pieces
• Starts with a content://
• It always has an authority, a unique string
identifying the content provider.
• It may have a data type path.
• It may have an instance identifier.
• Create a metadata class
10/3/2015
20
Local Databases
• Using SQLite - an open-source database engine.
– Space-efficient.
– Follows SQL-92 standard (most of the time).
– Android is shipped with sqlite3 database tool. Run
using command sqlite3 from shell.
– Manifest typing – defined as “In manifest typing, the
data type is a property of the value itself, not of the
column in which the value is stored. SQLite thus allows
the user to store any value of any data type into any
column regardless of the declared type of that
column.” (1)
(1): SQLite Documentation- http://www.sqlite.org/docs.html
10/3/2015
21
Local Databases
• Create a database: extend class
SQLiteOpenHelper
– Has methods for create and upgrade a database
– Use info from the metadata class
– See the demo example.
10/3/2015
22
Extending ContentProvider
• Method onCreate
– Create the database using SQLiteOpenHelper
object
• Method Insert
– Uses to sUriMatcher class identify the URI type.
– Uses a SQLiteOpenHelper to insert a row
• Update manifest file
- <provider android:name="personalInfoProvider"
android:authorities="demo.demo2.PersonalInfo" />
10/3/2015
23
Using a Content Provider
• Using ContentResolver object, you can add,
delete, or query the Content Provider.
• Example: inserting a row in a table
- Uri uri = getContentResolver().insert(Persons.CONTENT_URI,
values);
10/3/2015
24
Creating Services
• created when:
– manually started (via an API call)
– some activity tries connecting to the service (via a
RPC).
10/3/2015
25
Remote procedure calls (RPC)
• Declare the RPC
interface using
Android Interface
Definition Language
(AIDL).
• The aidl tool
generates a Java
interface definition
that must be made
available to both the
local and the remote
process.
10/3/2015
26
Android Dev Phone 1
• SIM-unlocked, hardwareunlocked, designed for
developers.
• Use it instead of the
emulator.
• Compatible with Android
1.0, can be updated.
• The device currently costs
$399.
• Thanks to Dr. Chuck
Anderson for providing one.
10/3/2015
• Selected specs for Android Dev
Phone 1:
– Touch screen
– Trackball
– 3.2 megapixel camera with
autofocus
– Wi-Fi
– GPS-enabled
– Bluetooth v2.0
• Handsfree profile v1.5
• Headset profile v1.0
– 3G WCDMA (1700/2100 MHz)
– Quad-band GSM
(850/900/1800/1900 MHz)
– QWERTY slider keyboard
– Includes 1GB MicroSD card (can be
replaced with up to 16GB ca
27
Publishing An Application
•
•
•
•
Versioning
Preparing to publish
Signing
Publishing
10/3/2015
28
Setting Application Version
• Define two attributes in the application's
manifest file:
– android:versionCode: an integer that represents
the version of the application code, relative to
other versions.
– android:versionName: a string that represents the
release version of the application code, as it
should be shown to users.
10/3/2015
29
Preparing to publish
• Test your application.
• Set a nice icon (png, jpg) and label (in manifest
file).
• Turn off logging and debugging and clean up
data/files
– Remove android:debuggable="true" attribute
from the <application> element of the manifest
• Compile and run.
10/3/2015
30
Signing Applications
• All installed applications must be digitally signed with a
certificate. Private is key held by the developer.
• Self-signed certificates. No certificate authority is
needed.
– standard tools Keytool and Jarsigner.
• Recommendations
– Sign all applications with the same certificate:
• Application upgrade
• Application modularity
• Code/data sharing through permissions
– Use a key with a validity period of 25 years or more
• For publishing applications on Android Market, the key must have
a validity period ending after 22 October 2033.
10/3/2015
31
Signing Applications [Contd.]
• Signing in Debug Mode: if developing with Eclipse/ADT, When we
run or debug an application, ADT signs the .apk with the debug
certificate, runs zipalign on the package, then installs it on the
selected emulator or connected device.
• Signing for Public Release:
1.
2.
3.
4.
•
Obtain a suitable private key
Compile the application in release mode
Sign your application with private key
Align the final APK package
With Eclipse/ADT, the Export Wizard can do all the above 4 steps!
10/3/2015
32
Publishing
• Install Android USB driver.
1. Connect your Android-powered device to your
computer's USB port.
2. Select "Locate and install driver software."
3. Select "Don't search online."
4. Select "I don't have the disk. Show me other
options."
5. Select "Browse my computer for driver software."
6. Click "Browse..." and locate the folder where you
copied the installation package.
• From Eclipse, run as usual.
10/3/2015
33
Conclusions
• Android offers a rich platform for developing cell
phone applications.
• Easier, more efficient than Java ME
• Drawbacks
– Android only runs Android applications (.apk). We
cannot directly run jars.
– Responsiveness can be poor due to the limitations of
Dalvik's automatic memory management.
– Developers reported compatibility issues between
versions 1.5 and 1.6.
– Many rumors!
10/3/2015
34
Symbian OS
• An OS for developing cell phone applications.
• The world's most popular mobile operating
system, 50% of smart phone sales.
• In 2008, Nokia bought the Symbian Co. and
announced the Symbian Foundation
– Will produce open-source version of Symbian.
10/3/2015
35
Symbian Platforms
• S60 Platform:
– Licensed by Nokia to other manufacturers
including Lenovo, LG Electronics, Panasonic and
Samsung.
– Supported languages:
• Symbian C++, Standard C/C++, Java ME, Python, C#,
Ruby and FlashLite.
– Latest edition: S60 5th Edition (2008)
• S40 Platform:
– For relatively less powerfull devices.
10/3/2015
36
S60 Platform and Device SDKs for
Symbian OS
• Download (free):
http://www.forum.nokia.com
• Eclipse plugins
– EclipseME.
http://sourceforge.net/projects/eclipseme/
– MTJ (Mobile Tools for Java)
http://download.eclipse.org/dsdp/mtj/updates/1.
0.1/stable/
10/3/2015
37
Descargar

Slide 1