• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Android application development

Android application development






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Android application development Android application development Presentation Transcript

    • Introduction toApplication Development Surendra Bajracharya Feb 4th, 2013
    • Android Development Agenda• What is Android?• Installation (Eclipse)• Android Application Fundamentals• Hello World/Android Demo using Eclipse• Demo using IntelliJ (Login UI)• Google Maps application demo• Comments/Feedback
    • Android Development What is Android?• Android is an open source operating system, createdby Google specifically for use on mobile devices (cellphones and tablets)• Linux based (2.6 kernel)• Can be programmed in C/C++ but most appdevelopment is done in Java (Java access to C Librariesvia JNI (Java Native Interface))
    • Android Development Android System Architecture
    • Android Development Different Android VersionsEach major release is named in alphabetical order after a dessert or sugary treat; forexample, version 1.5 Cupcake was followed by 1.6 Donut.Most Android devices to date still run the older OS version 2.3 Gingerbread that wasreleased on December 6, 2010, due to most lower-end devices still being released with it.
    • Android Development Installation (30 min ~ 1 hr)• Eclipse – www.eclipse.org/downloads/ – 3.5 or later version – Classic or a Java edition• Android SDK and Android Development Tools (ADT)Plugin – developer.android.com/sdk/requirements.html• JDK, version 5, 6, or 7
    • Android Development Android ADT Plugin and SDK• In Eclipse: – Navigate to Help | Install New Software – Follow the instructions on the android site to install the plugin.• Point Eclipse to the location of the Android SDK: – In Eclipse, navigate to Preferences | Android – Browse to or enter the location in the “SDK Location” text field. – Apply, then OK
    • Android Development
    • Android Development Install packages•In Eclipse, navigate to Window | Android SDK Manager• Install packages from the list – At least 2.2 and 2.3 for current phone development – One tablet package.
    • Android Development
    • Android Development IntelliJ IDEA (another IDE)•IntelliJ IDEA 12 offers advanced support for development Androidapplications with the latest Android 4.2 SDK.•Code Assistance•Refactorings•Deploy, run and debug Android applications either in emulator or ona real device.•UI Designer: With IntelliJ IDEA you can build rich UI for your Androidapplications easily by drag and drop. The designer provides supportfor layouts, custom components, device profiles, refactorings,morphing and quick-fixes.
    • Android Development Android Application Fundamentals•Android Applications are Collections of reusablecomponents.•An Android App may have multiple entry points, and mayuse components from other applications.•In Android, the flow of user interaction across one ormore applications is called a “Task.”
    • Android Development Application Components Activity ◦ Present a visual user interface for one focused endeavor the user can undertake ◦ Example: a list of menu items users can choose from Services ◦ Run in the background for an indefinite period of time ◦ Example: calculate and provide the result to activities that need it Broadcast Receivers ◦ Receive and react to broadcast announcements ◦ Example: announcements that the time zone has changed Content Providers ◦ Store and retrieve data and make it accessible to all applications ◦ Example: Android ships with a number of content providers for common data types (e.g., audio, video, images, personal contact information, etc.) Intents ◦ Hold the content of a message ◦ Example: convey a request for an activity to present an image to the user or let the user edit some text
    • Android Development AndroidManifest.xml•An applications contents are described in the AndroidManifest.xmlfile.•All Activities, Services, Content Providers, and Broadcast Receivers inan app must have an entry in this file.•Activities register the Intents they respond to using “Intent Filters”.•Security permissions, version info, and the minimum sdk version arealso registered in AndroidManifest.xml.
    • Android Development Resources• An applications resources are described in .xml files in the /respath• Include UI layouts, drawables, values (such as strings and styles),and even raw .xml files and other data.• Resources are accessed using Context.getResources() and theR class – The R class is defined in R.java, which is generated for each application. – Each resource is assigned a public static final int id (compile – time constant) in the R class.
    • Android Development Activities• An Activity is a unit of user interaction within an androidapplication.• Activities are represented by the Activity class – All android apps subclass Activity – Activities have methods that can be overridden to detect stages in the activity lifecycle.
    • Android Development Default android app package com.sourceallies.helloworldandroidapp; 1. The Activity import android.app.Activity; import android.os.Bundle; public class HelloActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hello); } } 2. onCreate is a lifecycle method of the Activity3. The content view of theActivity is set to main.xml
    • Android Development Lifecycle methods of Activity•onCreate()•onStart()•onResume()•onPause()•onRestart()•onStop()•onRestart()All lifecycle methods mustcall through to super!More Information:http://developer.android.com/reference/android/app/Activity.html
    • Android Development Android Emulator: 2.2 Device
    • Android Development Hello World/Android Demo...• Create a new AVD (Android Virtual Device)• Setup a new Android Project in Eclipse• Write/run the program Setting up an AVD• Open Eclipse and go to the Window tab• Select the AVD manager from the dropdown• Once the AVD manager is open, click New• Name your AVD, and then select a version of the Android API forthe device to use• Click “Create AVD” – let’s say myAVD•Cant find AVD or SDK manager in Eclipse - solve it by going to Window ->Customize Perspective, and under Command Groups Availability tab check the Android SDKand AVD Manager
    • Android Development Making an Android Project• In Eclipse, go to File->New->Project• Next, open the Android Folder and select Android Project• Setup your project, so itll run on your AVD (name it, select API,etc...)
    • Android Development Producing an Android App javacJava code Byte code dx .java .class Dalvik exe classes.dex aapt Byte code <xml> Other .class files AndroidManifest.xml .apk Android Package Kit <str> Resources
    • Android Development
    • Android Development Writing the Program• Open the .java file created by the project• Initially the code should look like this:
    • Android Development Writing the Program...continuedAfter the initial code of the .java file is generated, edit the code sothat it then looks like this:
    • Android Development Running the App• Once the program is complete, save it, and then go up to Run.• Eclipse will then start an appropriate AVD and load the app onto theemulator• Once the file is installed on the AVD, itll launch and you will havecompleted your first HELLO world/Android app!
    • Android DevelopmentRunning the App R.javaDo notmodify! activity_hello.xml strings.xml
    • Android Development AndroidManifest.xml
    • Android Development Important Filessrc/HelloActivity.java Activity which is started when app executesres/layout/activity_hello.xml Defines & lays out widgets for the activityres/values/strings.xml String constants used by appgen/R.java (Don’t touch!) Auto-generated file with identifiers from activity_hello.xml, strings.xml, and elsewhereAndroidManifest.xml Declares all the app’s components Names libraries app needs to be linked against Identifies permissions the app expects to be granted
    • Android Development Various Layoutshttp://developer.android.com/resources/tutorials/views/index.html
    • Android Development Various Widgetshttp://developer.android.com/resources/tutorials/views/index.html
    • Android Development Demo Using IntelliJ IDEA 12.0.1
    • Android Development Google Maps Demohttps://developers.google.com/maps/documentation/android/v1/mapkeyAndroid Maps API Key: 0qMq9sUdrh4V367erwY0h76w-hXBG9kzeV1R8bg
    • Android Development
    • Android Development THANKS!!! Comments/Feedback sbajracharya@sourceallies.com