TELE303, Wireless Networking, Semester 1, 2013

tediousfifthMobile - Wireless

Nov 12, 2013 (3 years and 5 months ago)

75 views

TELE303:Wireless Networking
Lecture:Mobile Development
Lecturer:Mark George (mgeorge@infoscience.otago.ac.nz)
Department of Information Science,University of Otago
Semester 1,2013
Topics covered in this lecture
• Mobile Development Issues
• Mobile platforms.
• Introduction to Android
TELE303 MOBILE DEVELOPMENT 1
Mobile Development Issues
Difficulty
The mobile platformis one of the hardest platforms to develop on.
• Fast moving target:
– New devices appear at a ridiculous rate.
– The platforms are being constantly updated.
– New platforms arrive every couple of years,and other platforms
die off.
– There is an arms race amongst the device manufacturers to add
new features to the devices.
– There is another arms race between the platforms to add new
features to the platforms.
TELE303 MOBILE DEVELOPMENT 2
• The devices themselves are limited:
– Input is clunky.Touch screens are imprecise.On-screen keyboards
are cramped and error-prone.
– Battery power is limited,particularly when making heavy use of
the screen or network.
– CPU,memory,and storage are limited.
• Due to device limitations component reuse is important.
• Applications need to survive being paused,or even terminated without
losing state.
• Manufacturers and even telco operators like to add their own
non-standard UI layer to differentiate their devices.
TELE303 MOBILE DEVELOPMENT 3
• There is ‘core’ functionality that can’t be interfered with.This means
the platforms have ‘exotic’ threading models.
– Like most platforms they use a single-threaded UI.
– Applications are actively prevented fromblocking the UI thread.
– Expensive tasks are not allowed to use the UI thread.
– The screen can only be updated on the UI thread.
• Mobiles devices are easy to steal so there are additional security
considerations.
• Different hardware responds to the ‘standard’ API differently.
• Debugging is difficult.Particularly if supporting multiple devices.
• Maintenance.Given the rate at which things change there will be a lot
of maintenance just keeping the app running.
TELE303 MOBILE DEVELOPMENT 4
Cost
Due to the difficulties mentioned above,mobile development is more
expensive than most people think.The following are very rough estimates
of cost.
• A quick and dirty app that does the job:$1-10k.
• A solid and reliable app that does the job and is easy to use:$20-30K.
• A solid app that runs on multiple platforms.Multiply by the number
of platforms – they all use different languages and architectures so
there is not a lot that can be reused.
• A ‘beautiful’ app.Multiply by 5 - 10.
• A class leading ‘beautiful’ app.Multiply by at least 20.
TELE303 MOBILE DEVELOPMENT 5
Why is ‘beautiful’ expensive?
• More effort needs to go into designing the UI.
• A lot of effort needs to go into theming the UI.
• Icons and images need to be created or licensed.
• New UI components will probably need to be created.
• OpenGL may need to be used.The most ‘beautiful’ apps tend to have
more in common with games than anything else.
TELE303 MOBILE DEVELOPMENT 6
TELE303,Wireless Networking,Semester 1,2013
Lecture Slides Lecture:Mobile Development 1
Mobile Platforms
Very quick overview of the platforms:
Android:Based on the Android Open Source Project (AOSP) which is the
bulk of the OS and platform.Large app store,which has very low barriers to
entry.Large,and growing market share.Many devices,and many versions of
the platform.Java or C++.Cross platformdeveloper tools.Uses Eclipse as
the IDE.
iOS:Apple.Much more controlled.Less maintenance due to less devices and
platformversions.Large app store,but Apple are very restrictive about what
can be put in the market.Large and growing market share.Objective-C.
Xcode is the IDE – MacOs only.
Windows Phone:Microsoft.Smaller app store,which Microsoft control.Few
devices.The only manufacturer with heavy commitment is Nokia.Less
maintenance due to low number of platformversions.Tiny market share,not
much evidence of growth..NET.Visual Studio is the IDE – Windows only.
TELE303 MOBILE DEVELOPMENT 7
Symbian:Once had massive market share (∼60%),but moved too
slowly to compete with iOS and Android,and is nowcompletely dead.
BlackBerry:Had majority market share in business arena,but again
moved to slowly and is now on life-support.
Others:Samsung are have something called ‘Tizen’.Canonical are
pushing a variant of Ubuntu named ‘Unbuntu Touch’ as a mobile OS.
Mozilla are pushing their own ‘Firefox OS’.All are Linux based.
TELE303 MOBILE DEVELOPMENT 8
HTML 5
Since the major platforms all have browsers that have good HTML 5
support you can create AJAX web applications that should work on all
platforms.
Pros:
• Cheapest option for cross-platformsupport.
• Centralised updates – no need to use app stores.
Cons:
• Very difficult to make apps look like native apps.
• Limited access to native APIs.
There are also frameworks like ‘PhoneGap’ that are geared around making
web apps that look native and can access the native APIs.
TELE303 MOBILE DEVELOPMENT 9
Android
The main components of an Android application are:
Manifest:An XML document that describes the application.
Resources:XML documents that defined localised strings,and layout
definitions for different sized screens.Also image and icon files for different
sized screens.
Activities:The ‘screens’ of the application.
Services:Background processes.
Broadcast Receivers:Event handlers that listen to systemevents.
Content Providers:For exposing data that can be shared with the rest of the
system.
Intents and Intent Filters:A messaging mechanismfor sharing information
between applications.Can be used to share activities between applications.
TELE303 MOBILE DEVELOPMENT 10
Java / XML
C / C++
C
http://en.wikipedia.org/wiki/File:Android-System-Architecture.svg
TELE303 MOBILE DEVELOPMENT 11
Manifest
The manifest file is an XML document named AndroidManifest.xml that
describes the application.This includes:
• Application version information,and the names to display to the user.
• Which activity is the ‘main’ activity.
• SDK version that the application requires.
• Resources like icons and logos.
• Permissions that the application uses.
• Features of the device that the application requires.
• Intents that the application responds too (via filters).
• Some other things as well (mentioned in the next lecture).
See:http://developer.android.com/guide/topics/manifest/manifest-intro.html
TELE303 MOBILE DEVELOPMENT 12
TELE303,Wireless Networking,Semester 1,2013
Lecture Slides Lecture:Mobile Development 2
Activities
Activities represent the screens of an application.
• They can be defined either programmatically,or via the XML layout
files.The XML approach is preferred.
• Activities are stacked.Each new activity appears on top of the
previous one.This allows for navigation via the ‘back’ button that all
Android devices have.
See:
http://developer.android.com/guide/components/tasks-and-back-stack.html
• Activities are short-lived.They can be paused at any time by either the
user or the system.They can be killed at any time by the systemif
resources need to be freed.
• For more information:
http://developer.android.com/guide/components/activities.html
TELE303 MOBILE DEVELOPMENT 13
Activity Life-cycle
TELE303 MOBILE DEVELOPMENT 14
Saving/Restoring Activity State
TELE303 MOBILE DEVELOPMENT 15
Services
A service is generally considered to be longer running than an activity.There is
no UI associated with a service.The systemis less likely to terminate a service
than an activity.
Services can be used for background tasks like uploading or downloading a file.
These sort of services can be ‘unbound’ in that they can exist longer than the
application that started them.The service terminates when it finishes its task.
Services can also be bound to an application.This allows the application to
interact with the service.An example would be a service that interacts with the
multimedia sub-systemto play a music file.The application can send the service
instructions to pause or play the music.Bound services would normally end when
the application ends.
For more information see:
http://developer.android.com/guide/components/services.html
TELE303 MOBILE DEVELOPMENT 16
Service Life-Cycle
TELE303 MOBILE DEVELOPMENT 17
Broadcast Receivers
A broadcast receiver is basically a systemevent handler.Applications can
send also broadcasts.
It has an onReceive message that is called when the event triggers.
The application manifest registers the receiver,and specifies which events
the receiver listen for.
Examples of events that might be worth receiving:
• Battery low.
• Screen turned off.
• Incoming phone call.
• Download complete.
TELE303 MOBILE DEVELOPMENT 18
TELE303,Wireless Networking,Semester 1,2013
Lecture Slides Lecture:Mobile Development 3
Content Providers
These are sort of like the Data Access Objects (DAOs) in Android.They
allow an application to share data with other applications,or with Android
sub-systems (such as the search sub-system).
If you don’t want to share data with other applications then there is no
need to use content providers – you can create your own private DAO
classes for managing your data.
Android provides content providers for accessing the user’s data such as
contacts,SMS messages,calendar etc.
See:
http://developer.android.com/guide/topics/providers/content-providers.html
TELE303 MOBILE DEVELOPMENT 19
Intents
Intents are the glue that link everything together.They allow applications
to communicate with each other,and with Android sub-systems.
Intents are objects that encapsulate messages.Applications and
sub-systems ‘listen’ for particular intents by registering intent filters.
Intents are used for the following purposes:
• Starting activities provided by other applications or sub-systems.For
example taking a photo.Android provides an activity for taking a
photo so you should use that activity rather than creating your own.
• Sending and receiving broadcasts.The broadcast messages are intents.
• Interacting with ‘intent services’.These are services that can start in
response to an intent.
See:http://developer.android.com/guide/components/intents-filters.html
TELE303 MOBILE DEVELOPMENT 20
The Permissions System
By default an application is not allowed to access any part of the system
that might cause harm.This includes access to the user’s data.
Android has an explicit permissions system.Applications must declare
which sensitive data and sub-systems they intend to use,and the user must
acknowledge these permissions when installing the app.
See:
http://developer.android.com/guide/topics/security/permissions.html
TELE303 MOBILE DEVELOPMENT 21
Readings
Take a good look at the Android Developer’s guide.
There are links to the interesting bits throughout this lecture.
References
• Previous TELE303 lectures fromChristopher Frantz and Michael
Winikoff.
• The Android Developer’s Guide.
http://developer.android.com/guide/components/index.html
• The life-cycle diagrams are fromthe Android Developer’s website and
are licensed under Creative Commons 2.5:
TELE303 MOBILE DEVELOPMENT 22
TELE303,Wireless Networking,Semester 1,2013
Lecture Slides Lecture:Mobile Development 4