Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 1 Android Training Rakesh Kumar Jha Rakesh Kumar Jha [email protected] Mob - 9886336619
Jun 29, 2015
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 1
Android Training
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Welcome to Android application development
Before we start this class, be sure you have your development environment set up. You need to:
• Download the Android SDK. (developer.android.com)
• Install the ADT plugin for Eclipse (if you’ll use the Eclipse IDE). (developer.android.com)
• Download the latest SDK tools and platforms using the SDK Manager.
• JDK
• Eclipse
• You can choose any environment (Windows, Linux, MacBook)
Feature –
• Free
• Huge docs available (google.com)
• Support site (to support dev)
• Shipment is free
• Open source
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 2
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 3
SDK Download & Installation
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Source of Software for Android
To Download Java JDK for Windows System, use below link and set environment variable:-
http://www.oracle.com/technetwork/java/javase/install-windows-189425.html
To Download Android SDK for Windows System, use below link : –
http://developer.android.com/sdk/index.html
To Download Android ADT plugin for Eclipse, use below link :-
http://developer.android.com/sdk/installing/installing-adt.html#Configure
To Download Eclipse (Eclipse 3.6.2 (Helios) or greater) , use below link :-
http://www.eclipse.org/downloads/
Configure environment setup (Java)
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 4
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Download the ADT Plugin
Other Way to Download/install ADT (if you already downloaded ADT, then leave this step and follow up from point 9 onward :-
1. Start Eclipse, then select Help > Install New Software....
2. Click Add, in the top-right corner.
3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
4. Click OK
Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
7. Read and accept the license agreements, then click Finish.Note: If you get a security warning saying that the authenticity or validity of the software can't be established, clickOK.
8. When the installation completes, restart Eclipse.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 5
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Download the ADT Plugin
Download/install ADT (if you already downloaded ADT, then follow up below points :-
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 6
Name Package Size MD5 Checksum
ADT 20.0.2 ADT-20.0.2.zip 12388464 bytes 8e727bcdc9789c900784a82e6330ec22
1.Download the current ADT Plugin zip file from the table below (do not unpack it).
2.Follow steps 1 and 2 in the default install instructions (above).
3.In the Add Site dialog, click Archive.
4.Browse and select the downloaded zip file.
5.Enter a name for the local update site (e.g., "Android Plugin") in the "Name" field.
6.Click OK.
7.Follow the remaining procedures as listed for default installation above, starting from step 4.
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Configure the SDK
After you've installed ADT and restarted Eclipse, you must specify the location of your Android SDK directory:
1. Select Window > Preferences... to open the Preferences panel (on Mac OS X, select Eclipse > Preferences).
2. Select Android from the left panel.
3. You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and clickProceed.
4. For the SDK Location in the main panel, click Browse... and locate your downloaded Android SDK directory (such asandroid-sdk-windows).
5. Click Apply, then OK.
Note – Prior to setup ADT or SDK, need to setup/config JDK1.5 or above
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 7
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Rakesh Kumar [email protected] - 9886336619
Updating the ADT Plugin
1. Select Help > Check for Updates.If there are no updates available, a dialog will say so and you're done.
2. If there are updates available, select Android DDMS, Android Development Tools, and Android Hierarchy Viewer, then click Next.
3. In the Update Details dialog, click Next.
4. Read and accept the license agreement and then click Finish. This will download and install the latest version of Android DDMS and Android Development Tools.
5. Restart Eclipse.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 8
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 9
Installing ADT Plugin
• Help -> Install New Software -> Add -> Archive -> write the name of ADT (mandatory, give any name)
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 10
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 11
Name – KTADB or SymADT or Anything
Location – Locate your ADT zip file (you downloaded)
Click OK button
Note – Please don’t unzip ADT
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 12
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 13
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 14
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
If checked “Always run in background”, this dialog will disappear.
If clicked Details button, then current package is installing will show like below, dialog with Detailed view
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 15
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure ADT
While installing ADT, you may get warning message like –
Note - You need to click OK button
Once, ADT install, it will ask to restart Eclipse, Eclipse will automatic restart like –
Note – Click Restart Now
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 16
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure Android SDK
• Windows > Android Sdk Manager>select package you want to install.
It will show all APIs level to be download.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 17
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
How to Configure Android SDK
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 18
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
First Project “HelloWorld” in Android
Create first project in Android
1. Click File Menu
2. Click New
3. Click Other option (if you are not getting Android option)
4. Drag Android Option at left side
5. Double click on Android Application Project
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 19
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
First Project “HelloWorld” in Android
6 You will get right side screen
7 Write application name say HelloWorld
8 Click Next button
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 20
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
First Project “HelloWorld” in Android
9 You will get right side screen (only in latest version of Android.
10 Click on Next button
11 Select Blank Activity
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 21
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
First Project “HelloWorld” in Android
12 Write Activity Name say HelloMainActivity
13 It will generate Automatic Layout say activity_hello_main
14 Click finish button
15 It will create Project with Project entire directory structure.
MVC structure
12 M – Model (.java) – Business logic
13 V – View (.xml) - UI
14 C – Controller (manifest) – Bind up all res
Database Name – Sq lite
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 22
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 23
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - Details
Project Directory Structure (main points)1. Create a new Project. File > Project > Android > Android Project.2. Name the project – HelloWorld,
Package Name: com.rakesh.helloworld,Applicationname: HelloWorld,Create Activity: HelloWorldActivityFinish
Project StructureAfter you create a new project in eclipse, you will see the following top-level folders in your package
explorer. • /src• /gen• /Android version• /assets• /bin• /res
• /drawable• /Layout
main.xml• /Values
Strings.xml• Androidmanifest.xml
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 24
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - Details
The structure of an Android Application
• src –
• Contains the .java source files for your project.
• HelloWorldActivity.java.
• This file is the source file for your activity.
• Android 2.2 Library –
• This item contains one file, android.jar, which contains all the class libraries needed for an Android application.
• gen –
• Contains the R.java file, a compiler-generated file that references all the resources found in your
• Android Project. You should not modify this file. As you add the files & folders in your application,
• Eclipse will automatically generate the content of R.java.
• assets –
• This folder contains all the assets used by your application, such as HTML, text files, databases, etc.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 25
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - Details
• res –
• This folder contains all the resources used in your application. It also contains a few
• sub-folders:
• drawable-<resolution>, layout, values.
• AndroidManifest.xml –
• This is the manifest file for your application.
• Here you specify the permissions needed by your application, as well as other features (such as intent-filters, receivers, etc.)
•
• strings.xml –
• Located in the res > values folder, is a file for storing all the string constants and reference the string using the @string identifier.
• This will ease your task of localizing your application to another language, all you need to do is replacing the string values from the local applications and recompile your application.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 26
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - Details
AndroidManifes.xml –
Every application must have the AndroidManifest.xml in its root directory.
It provides essential information about the application to the Android system, information the system must have before it can run any of the application's code.
These information are
Java package
Components of the application
Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts.
Declare the minimum API level required by the application, based on which APIs the application uses.
Declare hardware and software features used or required by the application, such as a camera, bluetooth services, or a multitouch screen.
API libraries the application needs to be linked against (other than the Android framework APIs), such as the Google Maps library.
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 27
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - Activity
package com.rakesh.helloworld;
import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.MenuItem;import android.support.v4.app.NavUtils;
public class HelloMainActivity extends Activity {
@Overridepublic void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);setContentView(R.layout.activity_hello_main);
}
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_hello_main, menu);return true;
}
}
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 28
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure - layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#505050" >
<TextViewandroid:id="@+id/text1"android:textColor="#000000"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:padding="@dimen/padding_medium"android:text="@string/hello_world"tools:context=".HelloMainActivity" />
<TextViewandroid:id="@+id/text2"android:textColor="#ffffff"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/text1"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:padding="@dimen/padding_medium"android:text="Welcome to Symphony Android Training Class"tools:context=".HelloMainActivity" />
</RelativeLayout>
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 29
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure – Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.rakesh.helloworld"android:versionCode="1"android:versionName="1.0" >
<uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="15" />
<applicationandroid:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activity
android:name=".HelloMainActivity"android:label="@string/title_activity_hello_main" ><intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /></intent-filter>
</activity></application>
</manifest>
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 30
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure
String.xml file <resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title">HelloMainActivity</string>
</resources>
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 31
Menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:orderInCategory="100"
android:showAsAction="never" /></menu>
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Create emulator
1. Click on Window Menu
2. Click on ADT Manager
3. New Window will come
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 32
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Create emulator
1. Click on New Button at right side
2. next screen will come
3. Fill details 1. Name – SymAVD
2. Target – APIs like 8, 10,12,14,16 (as requirement)
3. Click on Create AVD
4. It will create one emulator
5. Then close Android Virtual Device Manager
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 33
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure – Result Screen
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 34
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
HelloWorld Project Structure – Result Screen
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 35
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Run HelloWorld Project
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 36
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Run HelloWorld Project
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 37
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619
Thank You.Q ?
Copyright © 2012 Symphony Teleca Corp. All rights reserved. CONFIDENTIAL AND PROPRIETARY 38
Rakesh Kumar Jha Rakesh Kumar [email protected] - 9886336619