1 / 22

ANDROID PROGRAMMING MODULE 1 – GETTING STARTED

ANDROID PROGRAMMING MODULE 1 – GETTING STARTED. DEPARTMENT OF COMPUTER SCIENCE IOWA STATE UNIVERSITY. Concepts Android OS Android Programming Setting up the development environment. ADT Eclipse IDE SKD Manager Creating an Android Project More Concepts Activity

leal
Télécharger la présentation

ANDROID PROGRAMMING MODULE 1 – GETTING STARTED

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ANDROID PROGRAMMINGMODULE 1 – GETTING STARTED DEPARTMENT OF COMPUTER SCIENCEIOWA STATE UNIVERSITY

  2. Concepts • Android OS • Android Programming • Setting up the development environment. • ADT • Eclipse IDE • SKD Manager • Creating an Android Project • More Concepts • Activity • Basic Structure of an Android Project • Deployment ROADMAP

  3. Android OS • Android is an operating system based on the Linux kernel, and designed primarily for touchscreen mobile devices such as smartphones and tablet computers. • Android is open source and Google releases the source code under the Apache License. • Android Programming • Applications are usually developed in the Java programming language using the Android Software Development Kit, but other development tools are also available. Concepts

  4. The Development Environment for Android Contains the following Components: • Android Software Development Kit (SDK) • Android Development Tool Plugin (ADT Plugin) • Eclipse Integrated Development Environment (IDE) or some other IDE. • Google also provides an SDK Manager to Keep the SDK up to date. • To get these components go to http://developer.android.com/sdk/index.html and download the entire package including Eclipse for convenience. • There are other options for development like the android studio IDE for developing Android Projects. You can use any tool you are convenient with, however in the modules Eclipse with ADT Plugin is used. Setting up the Development EnvironmentDownload

  5. After Downloading the Package and extracting it. You will see that there are three items: • The Android SDK is composed of modular packages that you can download separately using the Android SDK Manager. For example, when the SDK Tools are updated or a new version of the Android platform is released, you can use the SDK Manager to quickly download them to your environment. Setting up the Development EnvironmentAndroid SDK and SDK Manager

  6. Open the Eclipse folder which contains the Eclipse IDE files and click on the Application file named Eclipse. • The first time one open’s the IDE, it requests to create a work space. Browse and select the folder to create the workspace where your projects will be saved. Setting up the Development EnvironmentEclipse IDE with ADT Plugin

  7. Now the Workbench Opens and one can see the Java Perspective set by default in the top right corner of the window. • To Create a new Android Project follow these steps. • Select File -> New -> Android Application Project. Creating an Android Project Java Perspective

  8. In the New Android Application Dialog, provide the application name and package name and click next. One can leave the SDK versions unmodified for this project. Creating an Android ProjectApplication and Package Names

  9. For the First Example Click Next in all the consecutive windows. • The Configure Project Window provides the option of creating a custom launcher Icon for your App and create the Main Activity for your Application. • The Main Activity is the point of entry into the application. Unlike other programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle. Creating an Android ProjectConfigure Project

  10. Click Next in the Configure Attribute for the icon art window • In the Create Activity Window select Blank Activity and Click Next. A Blank Activity will be created in the project which display’s a “Hello World” string. • Give a name for your blank activity in the Blank Activity Window and Click Finish. Creating an Android ProjectIcon and Activity

  11. You have just created an android Project. But before deploying it in a Mobile Phone or an Emulator, let us look at the structure of the project created. Creating an Android Project Contents of Project

  12. src : Contains source files and packages. • gen: Contains files generated on building the project. • bin: Contains class files and the generated Application Package (apk) file. • libs: Contains external libraries • res: Contains resourses such as drawable , strings , layout and other resouses used by the application in the form of xml files. • Android Manifest.xml : 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. Structure of the Android Project

  13. The manifest does the following: • It names the Java package for the application. The package name serves as a unique identifier for the application. • It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities. • It declares which permissions the application must have in order to access protected parts of the API and interact with other applications. Eg: <uses-permission android:name="android.permission.INTERNET"/> • It declares the minimum level of the Android API that the application requires. Eg: <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> • It lists the libraries that the application must be linked against. Android Manifest.xml

  14. There are two ways to deploy an application, the first is using a physical device and the second is to run the application on a virtual device. Two Ways of Debugging

  15. What is an Emulator? An emulator is a software that duplicates (or emulates) the functions of one computer system in another computer system. In the case of an Android Emulator , the Emulator software closely resembles the behavior of the real Android Device. • What is an Android Virtual Device (AVD)? As the name suggests it is a Virtual Device which emulates a real Android Device that runs the Android OS. It is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator. Android Emulator / Android Virtual Device

  16. Follow these steps to first create an Android Virtual Device (AVD) in the Eclipse IDE with ADT Plugin. • Go to the Window -> Android Virtual Device Manager. • In the Android Virtual Devices tab, Click on New.. • Or Go to the Device Definitions Tab and select a device and click on Create AVD. Setting up the AVD

  17. Now the Create New AVD window appears. Provide a Name for the AVD and complete the other Configuration options such ad the Android Version, Memory options etc. • Click OK. Now the AVD is created. • To start the emulator Open the AVD Manager and go to the AVDs tab. Select an AVD and click on Start.. (The emulator may take some time to load) Deploying an ApplicationIn AVD

  18. In order to debug you application in a real Android Device, the device must have ‘Developer Options’ enabled. • For each device this option can be enabled in different ways. For security reason, that this option may not be enabled by mistake it might be hidden. One can Search online in the Internet for a way to enable this option in one’s specific device. Setting up the Physical Device

  19. In order to run the application on your device. • One can connect the device to the computer using a USB cable and then Click on Run As -> Android Application , and choose from the list of devices available. Deploying an application In the Physical Device

  20. Or one can build the Application by selecting Project-> Build Project , which will generate the Android Package file (.apk file) which will be available in the bin folder of the project, which can be transferred to your phone by some means (say email) and then installed in the Device. Deploying in the Physical Device

  21. Ensure Project -> Build Automatically is Selected. • Now Click on the Project in the Package Explorer and Select Run-> Run As -> Android Application • Now select the device /AVD to run the application on. Deploying the Application

  22. Thank You!

More Related