This document outlines an agenda for an Android application development workshop covering topics like the Android system architecture, XML, building a "Hello World" app, project structure, basic user interaction and interconnection between activities using intents. The workshop will teach setting up the development environment, creating projects, adding activities, getting views in code, passing data between activities and referencing resources. Attendees will learn to build a basic two-screen app with interactivity and data passing between screens.
3. Agenda
What we will cover today
The Android System and the Android SDK.
The eXtensible Markup language (XML).
Building and running our first Application. (project structure -
AVDs)
The Project structure.
The First touch(Basic User-App Interaction)
Basic Interconnection.
Advanced Interconnection.
7. The XML - overview
<school >
- - - - - - -
</school>
Every starting tag has an end tag
The Tag may have a child tags
<hospital>
<doctor>
<patient ----> --- </patient>
<patient ----> --- </patient>
</doctor>
</hospital>
The Tag may contain attribute
<student name=Borhan age=23 ></student>
8. Android Application Development
1. The Installation of the development environment
2. The main application component The Activity.
3. The View System.
9. The Installation
What do you need to prepare the development environment?
1. The Android SDK
2. An editor to code your project or The Integrated
Development Environment (Eclipse IDE)
3. Connect the IDE and the SDK to begin developing for the
Android market (Android developer tool ADT)
( SDK + Eclipse )* ADT = My Android Development Environment
Remember:
SDK = Android development tools + Android application framework
10. Android Application development -
Activities
The activity:
the most important Android application component.
Its a java class that represent a Screen.
Each application must contain one screen .
This is an Activity
Note: The activity is not a layout
11. Android Application development
(create a simple layout) .cont
The view:
The view is the fundamental component you see in the
screen that is used to build layouts.
The views can be containers or a widgets.
13. Building the first application
Hello World, Android
1. Setup the Android projects workspace.
2. Create a new Android application project.
3.Launch the Android Application Project.
4.What is the project structure?
14. Create a new Android app project
1. Together lets setup the workspace
2. Project creation step 1
15. Create a new Android app project
3. Project creation step 2
16. Create a new Android app project
4. Project creation step 3
17. Create a new Android app project
5. Project creation step 4
18. Create a new Android app project
6. Project creation step 5
19. Create a new Android app project
(The Android virtual device AVD)
The Android Virtual Device (The Emulator)
20. The project structure - res
The static content of any Android
application is called a resource.
1. images.
2. Textual content.
3. Layouts.
4. Etc
The main idea to reach a resource is
that , each resource item must have
an ID.
To reach to a resource ID us in XML:
@resourceType/resourceID
Ex: @string/app_name
(in the AndroidManifest.xml)
22. The project structure AndroidManifest.xml
To Set the layout content of an Activity use the:
setContentView(int layoutResouceID);
23. Basic call Back
Android Toast
1. Assign Id to view to get them in code.
2. Get Views in code to manipulate them.
3.Build a basic call back mechanism.
24. Basic callbacks : get Views In Code
The Goal:
We Assign an ID to a view element like Buttons, TextView
so we can reach them in code.
The Way:
we set an id to the view element like (TextView , Button)
Using android:id=@+id/idName
In the Activity we call the view:
Using the Activity function: findViewById(int viewId)
viewId = R.layout.some_layout_resource_name
25. Basic callbacks : (The R class)
XML
resource
Java CodeR.java
public final class R {
public static final class string{
/** String array of all countries in the world
public static final int app_name=0x7f060001;
public static final int hello=0x7f060000;
}
-----
}
31. Start the new Activity
The Intent Object:
Intent intent = new Intent();
Put Some content in the message:
intent.putExtras(String key,Object vlaue);
Start The new Activity:
startActivity(intent);
Receive the intent object:
getIntent();
33. Interconnection between activities
(The Intent system)
Activity 2Activity 1
When you want to launch a new Activity from the current Activity
you need to use Intents.
The Intent represents the Application Intention to do something,
which is (launching a new Screen) .
You specifies the current Activity and the name of the Destination
Activity in the construction of intent object.
Intent intent = new Intent(this , destinationActivityName.class)
You can put extra content in the message that you send to launch a
new Activity.
Intent.putExtras( String key , value);
34. Interconnection between activities
(The Intent system) .cont
To launch the new Activity from the current activity use the
Activity method:
startActivity(Intent intent)
To get the Intent object that caused the activity to be launched:
In the destination Activity , use the activity method:
getIntent()
To extract the extra data from the intent based of the type of data
( like String data for instance ) : intent.getStringExtras(String key)