Introduction to the design and implementation of applications for handheld systems, such as smartphones and tablets, running the Android Platform.
- Takes 8 weeks
- Requires 3-6 hours of work / week
Introduction to the design and implementation of applications for handheld systems, such as smartphones and tablets, running the Android Platform.
The Android Architecture (bottom to top)
Typical Workflow
Dalvik VM Internals by Dan Bornstein
The Android Development Environment is your workbench for creating Android applications. Like any skilled crafts person, the more comfortable you are with your tools the easier it's going to be to produce top quality work.
Resources
Core application components include:
Resources
Device configuration can change at runtime. For e.g. keyboard, orientation and locale.
N.B. onRetainNonConfigurationInstance was deprecated in API Level 13.
An intent is an abstract description of an operation to be performed.
Intent Fields
Resources
To learn/investigate more about Intent Filters look at the following command:
$ adb shell dumpsys package
Android uses permissions to protect data, resources and operations.
Applications can also define and enforce their own permissions.
Resources
Fragments were added to Android in version 3.0 to better support user interfaces for devices with large screens such as tablets. They represent a portion of an activity's user interface. Fragments have a lifecycle which is coordinated with the lifecycle of its containing activity.
If you call setRetainInstance(true)
, Android won't destroy the fragment on configuration changes.
Resources
Views
View Events
View Groups
View groups are invisible views that contain other views. The are used to group and organize multiple views and view groups.
Some example view groups:
Adapters and Adapter Views
Adapter views are view groups whose child views and underlying data are managed by another class called an adapter.
Layouts
Layouts are generic view groups that are used to organize and structure other views and view groups.
Menus
Action Bar
Dialogs
Notifications are messages that applications show to users outside the normal user interface of the application.
Two different kinds of user notifications that Android supports:
For user feedback you can use:
For event notifications you can use:
Toast messages are temporary messages that pop-up on the display. They automatically fade in and fade out of view.
This kind of user notification appears in the system controlled area at the top of the device called the notification area or the status bar. Applications and the Android system itself can use this area to inform users about the occurrence of various events.
A pending intent is essentially a permission slip that allows one piece of code to stand in for another piece of code. This permission slip allows the second piece of code to activate the underlying intent as if it were the first piece of code, i.e. it does it with the permissions and identity of that first piece of code.
Typical use case:
onReceive()
method during which they handle the incoming event.BroadcastReceivers can register in two ways:
AndroidManaifest.xml
.registerReceiver()
method.Intents can be broadcast normally or in-order. Normal broadcasts are delivered to subscribed BroadcastReceivers in an undefined order. Ordered broadcasts deliver the intent to multiple BroadcastReceivers one at a time in priority order.
Broadcasts can also be sticky or non-sticky. A sticky broadcast sticks around after its initial broadcast. Non-sticky broadcasts are discarded after their initial broadcast.
Some debugging tips
Intent.setFlag(FLAG_DEBUG_LOG_RESOLUTION)
$ adb shell dumpsys activity b
$ adb shell dumpsys package
To learn more about concurrency in Java, check out:
To learn about process and threads in Android, check out: Processes and Threads.
The UI thread is the main thread.
The following methods guarantee execution on the UI thread:
Alarms are a mechanism for sending intents at some point (or points) in the future. This is useful because it allows an application to cause some other code to execute, even when that application is no longer running. Once alarms have been created and registered they are retained and monitored even if the device goes to sleep.
Alarm examples
To use alarms you do so by interacting with the AlarmManager. You do not instantiate this class directly; instead, retrieve it through Context.getSystemService(Context.ALARM_SERVICE).
Response data types:
Topics
Draw to a view when:
Draw to a canvas when:
The Drawable class represents things that can be drawn. For e.g. bitmaps, colors, shapes etc.
Drawing with a canvas, you will need:
A surface view provides a dedicated drawing surface embedded inside of a view hierarchy.
Resources
Topics
GestureDetector is a class that recognizes common touch gestures. Some built-in gestures include tap, double tap and fling.
Resources
Topics
F-Droid - FOSS Apps for Android