Day: 2 Environment Setup for Android Application Development

5,662 views

Published on

Published in: Education, Technology
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total views
5,662
On SlideShare
0
From Embeds
0
Number of Embeds
1,917
Actions
Shares
0
Downloads
378
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Day: 2 Environment Setup for Android Application Development

  1. 1. Android Application Development Getting Started Ahsanul Karim [email_address] Sentinel Solutions Ltd. http://www.sentinelbd.com
  2. 2. General Course Outline <ul><li>Introduction to Android and Mobile Devices </li></ul><ul><li>Setting up Development Environment </li></ul><ul><li>Application Architecture and Lifecycle </li></ul><ul><li>Java Language Basics and Syntax </li></ul><ul><li>Object Oriented Programming in Java </li></ul><ul><li>Vertical and Horizontal Libraries in Java </li></ul><ul><li>Object Oriented Principles and Practice </li></ul><ul><li>Building Android Applications </li></ul><ul><li>Android User Interface </li></ul><ul><li>Common Controls </li></ul><ul><li>Android Application Components: Activity, BroadcastListener, Service, Content Provider </li></ul>
  3. 3. <ul><li>System Requirements </li></ul>Setting up Development Environment <ul><li>Supported OS </li></ul><ul><li>Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit) </li></ul><ul><li>Mac OS X 10.5.8 or later (x86 only) </li></ul><ul><li>Linux (tested on Ubuntu Linux, Lucid Lynx) </li></ul><ul><li>Supported Development Environment (Eclipse IDE based) </li></ul><ul><li>Eclipse 3.4 (Ganymede) or greater/Eclipse Classic (versions 3.5.1 and higher) </li></ul><ul><li>JDK 1.5 or 1.6 </li></ul><ul><li>ADT Plugin </li></ul>
  4. 4. <ul><li>To set up the development environment, we need: </li></ul><ul><li>Java Development Kit (JDK 1.5+, 1.6 is preferable) </li></ul><ul><li>Eclipse IDE </li></ul><ul><li>Android SDK </li></ul>Setting up Development Environment(Contd.)
  5. 5. <ul><li>Java Development Kit (JDK) </li></ul>Setting up Development Environment (Contd.) Download Link: http://www.java.com/en/download/index.jsp Download JDK from here and Install JDK
  6. 6. <ul><li>Eclipse IDE </li></ul>Setting up Development Environment (Contd.) Download Link: http://eclipse.org/downloads/ Download the highlighted version of Eclipse IDE
  7. 7. <ul><li>Android SDK </li></ul>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)
  8. 8. <ul><li>Android SDK Setup (1) </li></ul>Setting up Development Environment (Contd.) 1. Install available packages to get all SDK platform versions
  9. 9. <ul><li>Android SDK Setup (2) </li></ul>Setting up Development Environment (Contd.) 2. Installation progress
  10. 10. <ul><li>Android SDK Setup (3) </li></ul>Setting up Development Environment (Contd.) <ul><li>3. ADT Plugin for Eclipse </li></ul><ul><li>ADT Plugin: </li></ul><ul><li>Android Development Tools (ADT) is a plugin for the Eclipse IDE for </li></ul><ul><li>extending the capabilities of Eclipse to set up new Android projects </li></ul><ul><li>creating an application UI </li></ul><ul><li>adding components based on the Android Framework API </li></ul><ul><li>debugging your applications using the Android SDK tools </li></ul><ul><li>exporting signed (or unsigned) APKs in order to distribute your application </li></ul><ul><li>We’ll see the 5 points gradually during development </li></ul>
  11. 11. <ul><li>Android SDK Setup (4) </li></ul>Setting up Development Environment (Contd.) 4. Installing the ADT <ul><li>Start Eclipse, then select Help > Install New Software... . </li></ul><ul><li>Click Add , in the top-right corner. </li></ul><ul><li>In the next window, you'll see a list of the tools to be downloaded. Click Next . </li></ul><ul><li>Read and accept the license agreements, then click Finish . </li></ul><ul><li>When the installation completes, restart Eclipse. </li></ul>
  12. 12. <ul><li>Android SDK Setup (5) </li></ul>Setting up Development Environment (Contd.) 5. Set SDK path <ul><li>Start Eclipse, then select Window > Preferences </li></ul><ul><li>Browse and show the path of Android SDK. </li></ul><ul><li>Press Apply and OK. </li></ul>Development Environment Setup is now completed!
  13. 13. Let’s say “Hello” to the Android World! <ul><li>In the subsequent slides: </li></ul><ul><li>We’ll create an application step by step using the help of IDE and ADT. </li></ul><ul><li>We’ll then explain application structure and identify the building blocks . </li></ul><ul><li>We’ll experiment with components and learn to convert our innovative ideas into neat apps. </li></ul>Now that our development environment is ready, we’ll build our first Android application.
  14. 14. 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.hallo 6. Initial Activity Name: HalloActivity 7. Min SDK Version: 4 8. Click Finish Congratulations! You’ve just created your first Android application We’ll explain each input shortly
  15. 15. 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
  16. 16. Let’s Go Deep… (Contd.) <ul><li>To run the app in emulator, we have to do the following steps: </li></ul><ul><li>Create AVD (Android Virtual Device) </li></ul><ul><li>Create Run Configuration </li></ul><ul><li>Run the Application </li></ul><ul><li>To run the app in device, we have to do the following steps: </li></ul><ul><li>Install device driver </li></ul><ul><li>Connect device through USB </li></ul><ul><li>Create Run Configuration </li></ul><ul><li>Run the Application </li></ul>We’ll run the app in emulator for now
  17. 17. Let’s Go Deep… (Contd.) 1. Create AVD (Android Virtual Device) Use Android SDK & AVD Manager to create AVD
  18. 18. Let’s Go Deep… (Contd.) 2. Create Run Configuration <ul><li>Create a Run Configuration </li></ul><ul><li>Browse and select the project to run </li></ul>
  19. 19. Let’s Go Deep… (Contd.) 3. Select AVD & Run Click Run to start AVD/emulator
  20. 20. Let’s Go Deep… (Contd.) Result in Emulator Now its time to analyze how it works
  21. 21. 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
  22. 22. 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
  23. 23. Project Structure (Contd.) -res/layout/main.xml <ul><li>UI Layout can be defined from source code using View or by layout xmls. </li></ul><ul><li>The layout xml can be generated by visual tool given by ADT </li></ul>
  24. 24. Project Structure (Contd.) -res/drawable <ul><li>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-mdpi </li></ul><ul><li>In our current project, they contain only default icon file with different dimensions to support devices with different screen resolution. </li></ul>-assets Holds 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
  25. 25. Project Structure (Contd.) -AndroidMenifest.xml XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application
  26. 26. Hmm.. No public static void main() ??? What is the Entry Point of an Android App? <ul><li>  Instead of main(), Android apps have the 4 essential components which can instantiate and run as needed : </li></ul><ul><ul><li>Activities </li></ul></ul><ul><ul><li>Services </li></ul></ul><ul><ul><li>Broadcast Receivers </li></ul></ul><ul><ul><li>Content Providers </li></ul></ul><ul><li>Whenever there's a request that should be handled by a particular component , Android makes sure that </li></ul><ul><li>the application process of the component is running , </li></ul><ul><li>starting it if necessary , and </li></ul><ul><li>that an appropriate instance of the component is available , </li></ul><ul><li>creating the instance if necessary . </li></ul>But how a request is made? What is the missing link?
  27. 27. Questions?

×