Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Android Overview 1
Agenda
M o b i l e Application Development (MAD)
Introduction to Android platform
Platform architecture
Application building blocks
L e t s Debug
Development tools.
Android Overview 2
Introduction to Android
O p e n software platform for mobile development
A complete stack – OS, Middleware, Applications
Powered by Linux operating system
F a s t application development in Java
O p e n source under the Apache 2 license
Android Overview 3
Android Overview 4
Application Framework
• API interface
• Activity manager – manages application
life cycle.
Android Overview 5
Applications
• Built in and user apps
• Can replace built in apps
Android Overview 6
Application Lifecycle
Application run in their own processes (VM, PID)
Processes are started and stopped as needed to run
an application's components
Android Overview
7
Application Building Blocks
Activity
Fragments
Intents
Service (Working in the background)
Content Providers
Broadcast receivers
A c t i o n bar
Android Overview 8
Activities
Typically correspond to one UI screen
R u n in the process of the .APK which installed
them
B u t , they can:
B e faceless
B e in a floating window
R e t u r n a value
Android Overview 9
Android Overview
10
Fragments
Fragment represents a behavior or a portion of user interface in an Activity.
You can combine multiple fragments in a single activity to build a multi-pane
UI and reuse a fragment in multiple activities.
Android Overview 12
Intents
An intent is an abstract description of an operation to be performed.
Launch an activity
Explicit
Ex: Intent intent = new Intent(MyActivity.this, MyOtherActivity.class)
Implicit : Android selects the best
Ex: Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(“tel:
555-2368”));
startActivity()
Extra parameter Ex: intent.putExtra(name, property);
context.startService(service);
S t a r t the service
Intent serviceIntent = new Intent();
serviceIntent.setAction
("com.wissen.testApp.service.MY_SERVICE");
startService(serviceIntent);
Android Overview
20
Example
private void displayRecords() {
String columns[] = new String[] { People.NAME,
People.NUMBER };
Uri mContacts = People.CONTENT_URI;
Cursor cur = managedQuery(mContacts, columns, null, null,
null );
if (cur.moveToFirst()) {
String name = null;
String phoneNo = null;
do {
name = cur.getString(cur.getColumnIndex(People.NAME));
phoneNo =
cur.getString(cur.getColumnIndex(People.NUMBER));
} while (cur.moveToNext());
}
}
Android Overview
21
Broadcast Receivers
A broadcast receiver is a class which extends
BroadcastReceiver and which is registered as a receiver in an
Android Application via the AndroidManifest.xml file(or via
code).
<receiver android:name="MyPhoneReceiver">
<intent-filter>
<action
android:name="android.intent.action.PHONE_STATE">
</action>
</intent-filter>
</receiver>
Android Overview
22
Broadcast Receivers
p u b l i c class MyBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,
”BR.”,Toast.LENGTH_LONG).show();
}
}
Android Overview
23
ActionBar
Android Overview
24
ActionBar
H o m e Icon area: The icon on the top left-hand side of the action
bar is sometimes called the “Home” icon.
Title area: The Title area displays the title for the action bar.
Ta b s area: The Tabs area is where the action bar paints the list
of tabs specified. The content of this area is variable.
Action Icon area: Following the Tabs area, the Action Icon area
shows some of the option menu items as icons.
M e n u Icon area: The last area is the Menu area. It is a single
standard menu icon.
Android Overview
25
Debugging
toast.show();
Android Overview
26
Debugging Cont.
•Hierarchy Viewer
•Connect your device or launch an emulator.
•If you have not done so already, install the application
you want to work with.
•Run the application, and ensure that its UI is visible.
•From a terminal, launch hierarchyviewer
Android Overview
27
Debugging Cont.
Android Overview
28
Debugging Cont.
Profiling for memory
Android Overview
29
Development Tools
Eclipse
developer.android.com
Android Overview
30
Thank You.