Android Step by Step
Android Step by Step
Disclaimer
Portions of this presentation are modifications based on work created and shared by the Android Open Source Project
> http://code.google.com/policies.html
They are used according to terms described in the Creative Commons 2.5 Attribution License
> http://creativecommons.org/licenses/by/2.5/
Get you be exposed to the basic building blocks of an Android application in a cursory manner
> The details will be covered in the rest of the course
Topics
Installation and configuration Building blocks of Android application
> > > > >
Activities Layout resource files AndroidManifest.xml Resource files - strings.xml R.java (created for you)
Software Needed
JDK (Java Development Kit)
> Java programming language is used to build Android
application
Eclipse IDE
> Editor, Debugger, profiler, deployment
Android SDK
> Libraries, samples, documentation, handset
development environment
Starting Activity class Layout resource file AndroidManifest.xml strings.xml R.java Android library
AndroidManifest.xml R.java (automatically created from resource files) Android library (automatically configured)
10
11
The onCreate() method of Activity class gets called by the Android system when your Activity starts
> You create your screen UI inside onCreate() method
Every Activity has to be described in the AndroidManifest.xml file An Activity is typically chosen as a starting one of your application - like a class that has a main() method in Java
> Through special configuration in AndroidManifest.xml
12
13
Each activity class specifies which layout resource file to use for each screen it represents
> Using setContentView(R.layout.main);
to as R.layout.main
14
15
The strings are then referred to through the names assigned to them
> The mapping is done through R.java > @string/hello (in the layout resource file) > R.string.hello (in the Java code)
16
17
AndroidManifest.xml file
Every application must have a manifest file called AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code.
18
application.
19
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name2"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="7" /> </manifest>
20
AndroidManifest.xml
21
R.java
Automatically created by Android system for all resources defined
22
R.java
23
24
Thank you!