The document discusses Android training which includes an introduction to Android, setting up the development environment, and building a "Hello World" Android application. It provides details on Android versions and the typical anatomy of an Android project, including files and folders for resources, code, and the manifest. It also outlines the activity lifecycle methods like onCreate(), onStart(), onResume(), etc.
1 of 27
More Related Content
Formation aimaf-android-part1
1. Android
Android Training Part 1
RGUIG Saad - AIMAF
lundi 21 janvier 13 1
2. Android
Morning Program :
1.General Introduction
2.Environment Setup
3.HelloWorl Application
4.Android Application Anatomy
lundi 21 janvier 13 2
4. General Introduction : Android
Android has more than 48 percent of the smartphone market, versus 32 percent for iOS.
Google indicates there are 850,000 Android device activations per day and total Google
Play app downloads have reached more than15 billion.App search 鍖rm Xyologic
reports that in March 2012 there were 617 million app downloads on Android versus 393
million app downloads on iPhone in the U.S.
lundi 21 janvier 13 4
20. Hello World Application Android
Android project anatomy
src/ Source folder contains all your Java source code
gen/ Generated folder contains source code generated by Android/Eclipse.
It contains R.java one of Androids most important 鍖le to perform name lookup/resolution and
referencing.
R.java is automatically generated by the build system and references your resources.
assets/ Assets folder contains static 鍖les such as html which can be included in your program.
res/ Resource folder contains your program resource 鍖les.
res/drawables/ Contains image 鍖les eg. PNG, JPG etc but also drawables which are speci鍖ed in
XML format
res/layouts/ Contains XML 鍖les to specify your application View layouts
res/values/ Contains XML 鍖les where you can specify static string,text, numeric and other
constant values.
libs/ A folder containing third-party/downloaded JAR libraries which can be used in your Android
App.
AndroidManifest.xml A manifest 鍖le where you can specify all you Activities, Permissions, and
other con鍖gurations.
lundi 21 janvier 13 20
24. Hello World Application Android
Android Activity Life cycle
Method Description
Called when the activity is 鍖rst created. This is where you should
do all of your normal static set up create views, bind data to lists,
and so on. This method is passed a Bundle object containing the
onCreate() activity's previous state, if that state was captured (see Saving
Activity State, later).
Always followed by onStart().
Called after the activity has been stopped, just prior to it being
started again.
onReStart() Always followed by onStart()
Called just before the activity becomes visible to the user.
Followed by onResume() if the activity comes to the foreground,
onStart() or onStop() if it becomes hidden.
lundi 21 janvier 13 24
25. Hello World Application Android
Android Activity Life cycle
Called just before the activity starts interacting with the user. At this point the activity is at
onResume() the top of the activity stack, with user input going to it.
Always followed by onPause().
Called when the system is about to start resuming another activity. This method is
typically used to commit unsaved changes to persistent data, stop animations and other
things that may be consuming CPU, and so on. It should do whatever it does very quickly,
onPause() because the next activity will not be resumed until it returns.
Followed either by onResume() if the activity returns back to the front, or by onStop() if
it becomes invisible to the user.
Called when the system is about to start resuming another activity. This method is
typically used to commit unsaved changes to persistent data, stop animations and other
things that may be consuming CPU, and so on. It should do whatever it does very quickly,
onStop() because the next activity will not be resumed until it returns.
Followed either by onResume() if the activity returns back to the front, or by onStop() if
it becomes invisible to the user.
Called before the activity is destroyed. This is the 鍖nal call that the activity will receive. It
could be called either because the activity is 鍖nishing (someone called finish() on it),
onDestroy() or because the system is temporarily destroying this instance of the activity to save
space. You can distinguish between these two scenarios with theisFinishing()
method.
lundi 21 janvier 13 25
26. Hello World Application Android
Android Activity Life cycle
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
lundi 21 janvier 13 26