day: 2 environment setup for android application development
TRANSCRIPT
![Page 1: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/1.jpg)
Android Application Development
Getting Started
Ahsanul Karim [email protected]
Sentinel Solutions Ltd.http://www.sentinelbd.com
![Page 2: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/2.jpg)
General Course Outline• Introduction to Android and Mobile Devices• Setting up Development Environment• Application Architecture and Lifecycle• Java Language Basics and Syntax• Object Oriented Programming in Java• Vertical and Horizontal Libraries in Java• Object Oriented Principles and Practice• Building Android Applications• Android User Interface• Common Controls• Android Application Components: Activity, BroadcastListener,
Service, Content Provider
![Page 3: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/3.jpg)
System RequirementsSetting up Development Environment
Supported OS1.Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit)2.Mac OS X 10.5.8 or later (x86 only)3.Linux (tested on Ubuntu Linux, Lucid Lynx)
Supported Development Environment (Eclipse IDE based)1.Eclipse 3.4 (Ganymede) or greater/Eclipse Classic (versions 3.5.1 and higher)2.JDK 1.5 or 1.63.ADT Plugin
![Page 4: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/4.jpg)
To set up the development environment, we need:1. Java Development Kit (JDK 1.5+, 1.6 is preferable)2. Eclipse IDE3. Android SDK
Setting up Development Environment(Contd.)
![Page 5: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/5.jpg)
Java Development Kit (JDK)
Setting up Development Environment (Contd.)
Download Link: http://www.java.com/en/download/index.jsp
Download JDK from here and Install JDK
![Page 6: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/6.jpg)
Eclipse IDE
Setting up Development Environment (Contd.)
Download Link: http://eclipse.org/downloads/
Download the highlighted version of Eclipse IDE
![Page 7: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/7.jpg)
Android SDK
Setting up Development Environment (Contd.)
Link: http://developer.android.com/sdk/index.html
Download and Install the SDK starter package from the table above (Highlighted)
![Page 8: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/8.jpg)
Android SDK Setup (1)
Setting up Development Environment (Contd.)
1. Install available packages to get all SDK platform versions
![Page 9: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/9.jpg)
Android SDK Setup (2)
Setting up Development Environment (Contd.)
2. Installation progress
![Page 10: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/10.jpg)
Android SDK Setup (3)
Setting up Development Environment (Contd.)
3. ADT Plugin for Eclipse
ADT Plugin: Android Development Tools (ADT) is a plugin for the Eclipse IDE for
1.extending the capabilities of Eclipse to set up new Android projects2.creating an application UI3. adding components based on the Android Framework API4. debugging your applications using the Android SDK tools5. exporting signed (or unsigned) APKs in order to distribute your application
We’ll see the 5 points gradually during development
![Page 11: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/11.jpg)
Android SDK Setup (4)
Setting up Development Environment (Contd.)
4. Installing the ADT
1. Start Eclipse, then select Help > Install New Software....
2. Click Add, in the top-right corner.
3. In the next window, you'll see a list of the tools to be downloaded. Click Next.
4. Read and accept the license agreements, then click Finish.
5. When the installation completes, restart Eclipse.
![Page 12: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/12.jpg)
Android SDK Setup (5)
Setting up Development Environment (Contd.)
5. Set SDK path
1. Start Eclipse, then select Window > Preferences
2. Browse and show the path of Android SDK.
3. Press Apply and OK.
Development Environment Setup is now completed!
![Page 13: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/13.jpg)
Let’s say “Hello” to the Android World!
In the subsequent slides: 1.We’ll create an application step by step using the help of IDE and ADT.2.We’ll then explain application structure and identify the building blocks.3.We’ll experiment with components and learn to convert our innovative ideas into neat apps.
Now that our development environment is ready, we’ll build our first Android application.
![Page 14: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/14.jpg)
Let’s say “Hello” to the Android World! (Contd.)1. Start Eclipse and Go to File>New>Android Project
2. We keep project name “Hello World” (Since 1970 Ritchie’s book on C programming, programmers always say Hello World first)3. Build Target “Android1.6”4. Application name: “Hello World”5. Package name: com.sentinelbd.hallo6. Initial Activity Name: HalloActivity7. Min SDK Version: 48. Click Finish
Congratulations! You’ve just created your first Android application
We’ll explain each input shortly
![Page 15: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/15.jpg)
Let’s Go Deep…Created Project has the following structure
Project Structure
-Source (src)-Generated Class (gen)-Android 1.6 library-Assets (assets)-Resource(res) -drawable-hdpi -drawable-ldpi -drawable-mdpi -layout -values-AndroidMenifest.xml-default.properties
![Page 16: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/16.jpg)
Let’s Go Deep… (Contd.)To run the app in emulator, we have to do the following steps:
1.Create AVD (Android Virtual Device)2.Create Run Configuration3.Run the Application
To run the app in device, we have to do the following steps:
1.Install device driver2.Connect device through USB3.Create Run Configuration4.Run the Application
We’ll run the app in emulator for now
![Page 17: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/17.jpg)
Let’s Go Deep… (Contd.)1. Create AVD (Android Virtual Device)
Use Android SDK & AVD Manager to create AVD
![Page 18: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/18.jpg)
Let’s Go Deep… (Contd.)2. Create Run Configuration
1. Create a Run Configuration
2. Browse and select the project to run
![Page 19: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/19.jpg)
Let’s Go Deep… (Contd.)3. Select AVD & Run
Click Run to start AVD/emulator
![Page 20: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/20.jpg)
Let’s Go Deep… (Contd.)Result in Emulator
Now its time to analyze how it works
![Page 21: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/21.jpg)
Project Structure…Created Project has the following structure
Project Structure
-Source (src)-Generated Class (gen)-Android 1.6 library-Assets (assets)-Resource(res) -drawable-hdpi -drawable-ldpi -drawable-mdpi -layout -values-AndroidMenifest.xml-default.properties
![Page 22: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/22.jpg)
Project Structure (Contd.)-Source (src)We have used only one class here which is an Activity named HalloActivity. We’ll describe about Activity in detail with lifecycle shortly. For now we can consider Activity as Android analogue for the window or dialog in a desktop application. It can load view from xml layout (here main.xml under res/layout folder)
In the HelloActivity class the view of the Activity is set from main.xml given below
![Page 23: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/23.jpg)
Project Structure (Contd.)-res/layout/main.xml
1. UI Layout can be defined from source code using View or by layout xmls. 2. The layout xml can be generated by visual tool given by ADT
![Page 24: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/24.jpg)
Project Structure (Contd.)-res/drawable1. From Android 1.6 to support different screen sizes and screen densities graphic files
are kept in 3 different folders drawable-hdpi, drawable-ldpi and drawable-mdpi2. In our current project, they contain only default icon file with different dimensions
to support devices with different screen resolution.
-assetsHolds other static files you wish packaged with the application for deployment onto the device. In this project, we have none
-gen/R.java -values/strings.xml
![Page 25: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/25.jpg)
Project Structure (Contd.)-AndroidMenifest.xml
XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application
![Page 26: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/26.jpg)
Hmm.. No public static void main() ???What is the Entry Point of an Android App?
Instead of main(), Android apps have the 4 essential components which can instantiate and run as needed:
1. Activities2. Services3. Broadcast Receivers4. Content Providers
Whenever there's a request that should be handled by a particular component, Android makes sure that 1.the application process of the component is running, 2.starting it if necessary, and 3.that an appropriate instance of the component is available, 4.creating the instance if necessary.
But how a request is made? What is the missing link?
![Page 27: Day: 2 Environment Setup for Android Application Development](https://reader035.vdocuments.mx/reader035/viewer/2022062513/5556ca97d8b42abb428b53f9/html5/thumbnails/27.jpg)
Questions?