Professional Documents
Culture Documents
DTECHANE6@GMAIL.COM
A Workshop on Android App Development 2 1 - F E B - 1 7
1
outline
Overview of mobile phone operating system
Various notifications
BY DEJENE TECHANE 2
What is an Operating System(OS)?
An operating system is the most important software that runs
on a computer.
BY DEJENE TECHANE 4
Mobile os (Contd...)
Modern smartphones are closer to handheld computers that enable us to:-
send emails,
play games,
and make video calls to loved ones. And much more besides.
BY DEJENE TECHANE 5
Mobile os (Contd...)
There are hundreds of thousands of apps available and they are
constantly being developed - each with their own purpose.
Google Android,
BY DEJENE TECHANE 6
Mobile os (Contd...)
Theres no hope of anyone catching up to Android and iOS
BY DEJENE TECHANE 7
What is android os?
Android OS is owned by Google and powered by the Linux
kernel, which can be found on a wide range of devices.
BY DEJENE TECHANE 8
android os architecture
Android OS is a stack of software components which is roughly divided into five
sections and four main layers as shown below in the architecture diagram.
BY DEJENE TECHANE 9
What is android os?(contd...)
Android is currently the dominant smartphone
platform due to its tremendous traction with a wide
spectrum of users.
BY DEJENE TECHANE 10
Features of android os
Feature Description
Media support H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-
AAC, AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG,
GIF, and BMP.
BY DEJENE TECHANE 11
Features of android os (contd...)
Feature Description
Media support H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-
AAC, AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG,
GIF, and BMP.
BY DEJENE TECHANE 12
Features of android os (contd...)
Feature Description
Web Browser Based on the open-source WebKit layout engine, coupled with
Chrome's V8 JavaScript engine supporting HTML5 and CSS3
Multi-touch Android has native support for multi-touch which was initially
made available in handsets such as the HTC Hero.
Multi-tasking User can jump from one task to another and same time various
application can run simultaneously.
BY DEJENE TECHANE 13
What is android programming?
Android programming is based on Java programming
language so if you have basic understanding on Java
programming
BY DEJENE TECHANE 14
What is android programming?
In general, Android programming is an integration of Java
programing and XML.
This includes a compiler, debugger and a device emulator, as well as its own virtual
machine to run Android programs.
BY DEJENE TECHANE 15
What is android applications (apps)?
Android apps is an application software that can run on the
android based smartphone to perform specific functions such
examples are:-
An app to send message to your friend or family
Etc. ....
BY DEJENE TECHANE 16
What is android application (contd...)?
Android applications are usually developed in the Java
language using the Android Software Development Kit.
BY DEJENE TECHANE 17
Android application components
Application components are the essential building blocks of
an Android application.
BY DEJENE TECHANE 18
Android application components
Activities :They dictate the UI and handle the user
interaction to the smartphone screen .
BY DEJENE TECHANE 19
Android application components(contd...)
An activity is implemented as a subclass of Activity class as follows:
If an application has more than one activity, then one of them should
be marked as the activity that is presented when the application is
launched.
BY DEJENE TECHANE 20
Android application components(contd...)
BY DEJENE TECHANE 21
Android application components(contd...)
BY DEJENE TECHANE 22
Android application components(contd...)
onCreate() :This is the first callback and called
when the activity is first created.
onStart() :This callback is called when the activity
becomes visible to the user.
onResume():This is called when the user starts
interacting with the application.
onPause() :The paused activity does not receive
user input and cannot execute any code and called
when the current activity is being paused and the
previous activity is being resumed.
BY DEJENE TECHANE 23
Android application components(contd...)
BY DEJENE TECHANE 24
Android application components(contd...)
Services :They handle background processing associated
with an application.
BY DEJENE TECHANE 25
Android application components(contd...)
BY DEJENE TECHANE 26
Android application components(contd...)
BY DEJENE TECHANE 27
Android application components(contd...)
A content provider component supplies data from one application to others
on request.
BY DEJENE TECHANE 28
Android application components(contd...)
Additional Components
Views : UI elements that are drawn onscreen including buttons, lists forms
Layouts: View hierarchies that control screen format and appearance of the
views.
BY DEJENE TECHANE 29
Android application components(contd...)
BY DEJENE TECHANE 30
Q&A?
Next ?
BY DEJENE TECHANE 31
Getting started with ADT
BY DEJENE TECHANE 32
Environment setup
You will be glad to know that you can start your Android
application development on either of the following operating
systems:
Microsoft Windows 7,8,10.
BY DEJENE TECHANE 33
Environment setup(contd...)
Second point is that all the required tools to develop Android applications
are freely available and can be downloaded from the Web.
Following is the list of software's you will need before you start your
Android application programming.
Java JDK7 or JDK8 (mandatory)
Android SDK (mandatory)
Eclipse IDE for Java Developers (optional)
Android Development Tools (ADT) Eclipse Plugin (optional)
Android studio(optional)
BY DEJENE TECHANE 34
Steps to setup ADT:
BY DEJENE TECHANE 35
Step 1: setup java development kit(jdk)
BY DEJENE TECHANE 36
Step 1: setup java development kit(jdk)
Finally set PATH and JAVA_HOME environment variables to
refer to the directory that contains java and javac, typically
java_install_dir/bin and java_install_dir respectively.
set PATH=C:\jdk1.6.0_15\bin;%PATH%
set JAVA_HOME=C:\jdk1.6.0_15
BY DEJENE TECHANE 37
Step 1: setup java development kit(jdk)
BY DEJENE TECHANE 38
Step 2: Setup android sdk
You can download the latest version of Android SDK from
Android official website : Android SDK Downloads.
BY DEJENE TECHANE 39
Step 2: Setup android sdk
BY DEJENE TECHANE 40
Step 3: Setup eclipse ide
To install Eclipse IDE, download the latest Eclipse binaries from
http://www.eclipse.org/downloads/
BY DEJENE TECHANE 41
Step 3: Setup eclipse ide
%C:\eclipse\eclipse.exe
BY DEJENE TECHANE 42
Step 4: android development toot (adt) plugin
BY DEJENE TECHANE 43
Step 5: create android vertual device(avd)
BY DEJENE TECHANE 44
Step 5: create android vertual device(avd)
BY DEJENE TECHANE 45
Step 6: create helloworld app
BY DEJENE TECHANE 46
Step 6: create helloworld app
Follow the option File -> New -> Project and finally select
Android New Application wizard from the wizard list.
BY DEJENE TECHANE 47
BY DEJENE TECHANE 48
Folder, file and description
Folder , file Description
1. src This contains the .java source files for your project. By default, it includes an
MainActivity.java source file having an activity class that runs when your app
is launched using the app icon.
2. gen This contains the .R file, a compiler-generated file that references all the
resources found in your project. You should not modify this file.
3. bin This folder contains the Android package files .apk built by the ADT during
the build process and everything else needed to run an Android application.
4. res/drawable-hdpi This is a directory for drawable objects that are designed for high-density
screens.
5. res/layout This is a directory for files that define your app's user interface.
BY DEJENE TECHANE 49
Folder, file and description
6. res/values This is a directory for other various XML files that contain a
collection of resources, such as strings and colors definitions.
BY DEJENE TECHANE 50
The Main Activity File
BY DEJENE TECHANE 51
The Main Activity File
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true; }}
BY DEJENE TECHANE 52
The Manifest File
BY DEJENE TECHANE 53
The Manifest File
For example, a default manifest file will look like as following file:
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity> </application>
BY DEJENE TECHANE 54
The Manifest File
For example, a default manifest file will look like as following file:
BY DEJENE TECHANE 55
The Strings File
The strings.xml file is located in the res/values
folder and it contains all the text that your application
uses.
BY DEJENE TECHANE 56
The Strings File
<resources>
<string name="app_name">HelloWorld</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>
BY DEJENE TECHANE 57
Congratulation!!
BY DEJENE TECHANE 58
What is intent?
BY DEJENE TECHANE 59
EXPLICIT INTENTS:
BY DEJENE TECHANE 60
EXPLICIT INTENTS
For example:
// Explicit Intent by specifying its class name
i.putExtra("Key1", "ABC");
i.putExtra("Key2", "123");
// Starts TargetActivity
startActivity(i);
BY DEJENE TECHANE 61
IMPLICIT INTENTS
BY DEJENE TECHANE 62
IMPLICIT INTENTS
For example:
// Implicit Intent by specifying a URI
startActivity(i);
BY DEJENE TECHANE 63
Practical exercise
Navigation app
Which is navigating from one screen to another
when button is clicked
BY DEJENE TECHANE 64
Understanding various notifications
What is Toast
It only fills the amount of space required for the message and the
current activity remains visible and interactive.
BY DEJENE TECHANE 65
Understanding various notifications
Basics
This method takes three parameters: the application Context, the text
message, and the duration for the toast.
You can display the toast notification with show(), as show in the following
example:
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
BY DEJENE TECHANE 66
Understanding various notifications
A dialog is a small window that prompts the user to make a decision or enter
additional information.
A dialog does not fill the screen and is normally used for modal events that
require users to take an action before they can proceed.
What is alert-dialog?
A dialog that can show a title, up to three buttons, a list of selectable items, or a
custom layout.
BY DEJENE TECHANE 67
Understanding various notifications
BY DEJENE TECHANE 68
Understanding various notifications
BY DEJENE TECHANE 69
Practical exercise
Phone Call
Tele Services
BY DEJENE TECHANE 70
References
https://developer.android.com/guide/index.html
BY DEJENE TECHANE 71