III B.tech II Sem Mad Unit-1 Lecture Notes
III B.tech II Sem Mad Unit-1 Lecture Notes
PREPARED BY
M.JEEVAN KUMAR
ASSOCIATE PROFESSOR
Syllabus
Android is an open source and Linux-based Operating System for mobile devices such as smartphones
and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other
companies.
Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in October,
2003.
Android offers a unified approach to application development for mobile devices which means developers
need only develop for Android, and their applications should be able to run on different devices powered
by Android.
The first beta version of the Android Software Development Kit (SDK) was released by Google in 2007
where as the first commercial version, Android 1.0, was released in September 2008.
On June 27, 2012, at the Google I/O conference, Google announced the next Android version, 4.1 Jelly
Bean. Jelly Bean is an incremental update, with the primary aim of improving the user interface, both in
terms of functionality and performance.
The source code for Android is available under free and open source software licenses. Google publishes
most of the code under the Apache License version 2.0 and the rest, Linux kernel changes, under the
GNU General Public License version 2.
Why Android?
Features of Android:
Android is a powerful operating system competing with Apple 4GS and supports great features. Few of
themare listed below:
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Feature Description
Beautiful UI Android OS basic screen provides a beautiful and intuitive user interface.
Connectivity GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and
WiMAX.
Storage SQLite, a lightweight relational database, is used for data storage purposes.
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3,
Media support MIDI,Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP
Messaging SMS and MMS
Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript
Web browser
engine supporting HTML5 and CSS3.
Android has native support for multi-touch which was initially made available in
Multi-touch handsets such as the HTC Hero.
User can jump from one task to another and same time various application can run
Multi-tasking
simultaneously.
Resizable Widgets are resizable, so users can expand them to show more content or shrink them to
widgets save space
Multi-Language Supports single direction and bi-directional text.
A technology that lets apps discover and pair directly, over a high-bandwidth peer-to-
Wi-Fi Direct
peerconnection.
Android Applications:
Android applications are usually developed in the Java language using the Android Software Development
Kit.
Once developed, Android applications can be packaged easily and sold out either through a store such
as Google Play, SlideME, Opera Mobile Store, Mobango, F-droid and the Amazon Appstore.
Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It's
the largest installed base of any mobile platform and growing fast. Every day more than 1 millionnew
Android devices are activated worldwide.
Entertainment
Tools
Communication
Productivity
Personalization
Music and Audio
Social
Media and Video
Travel and Local etc.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
History of Android
The code names of android ranges from A to L currently, such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo,
Gingerbread, Honeycomb, Ice Cream Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the android
history in a sequence.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Android Versions:
The android platform provides a framework API that applications can use to interact with the underlying Android
system. The framework API consists of a core set of packages and classes;
XML elements for declaring layouts, resources, and so on; a manifest file to configure applications; intents;
and much more.
Framework API is specified through an integer called API level, and each Android platform version supports
exactly one API level, although backward compatibility is there; that is, earlier API levels are supported.
Versions 1.0 and 1.1 were not released under specific code names.
Android code names are confectionery (sweets and chocolates collectively) themed and have been in
alphabetical order since 2009’s Android 1.5 cupcake, with most recent version.
Android versions should be listed below with version number, name, release date and API level.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
1. Linux kernel:
This is kernel on which Android is based.
This layer contains all low level device drivers for various hardware components of android
device.
2. Libraries:
These contain all code that provides main features of android OS.
SQlite libraries provide database support.
Web kit libraries provide functionalities for web browsing.
Surface manager library provides 2D and 3D graphics.
Free type library provides font support.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Media framework provides recording and playback of audio and video formats.
SSL libraries responsible for internet security.
Android Libraries
This category encompasses those Java-based libraries that are specific to Android development.
Examples of libraries in this category include the application framework libraries in addition to those
that facilitate user interface building, graphics drawing and database access. A summary of some key
core Android libraries available to the Android developer is as follows –
android.app − Provides access to the application model and is the cornerstone of all
Androidapplications.
Having covered the Java-based core libraries in the Android runtime, it is now time to turn our
attention to the C/C++ based libraries contained in this layer of the Android software stack.
3. Android runtime:
This is the third section of the architecture and available on the second layer from the bottom. Thissection
provides a key component called Dalvik Virtual Machine which is a kind of Java VirtualMachine specially
designed and optimized for Android.
The Dalvik VM makes use of Linux core features like memory management and multi-
threading, which is intrinsic in the Java language. The Dalvik VM enables every Android
application to run inits own process, with its own instance of the Dalvik virtual machine.
The Android runtime also provides a set of core libraries which enable Android application
developers to write Android applications using standard Java programming language.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
4. Application framework:
The Application Framework layer provides many higher-level services to applications in the form
ofJava classes. Application developers are allowed to make use of these services in their
applications.
Activity Manager − Controls all aspects of the application lifecycle and activity stack.
Content Providers − Allows applications to publish and share data with other applications
Notifications Manager − Allows applications to display alerts and notifications to the user.
View System − An extensible set of views used to create application user interfaces.
5. Applications:
At this top layer, you will find applications that ship with device (such as phone, contents,
browser ..... etc).
You will find applications that you download and install from Android Market.
Three categories of features (Development tools, source code an public JRE) are displayed and you
select from dropdown list to choose features you want to install.
Default location displayed is c:\program files\java\jdk1.8.0\,but you can use change button to select
another location.
Keep default settings and click next features are installed followed by dialog box with default folder
to install JRE (Java Runtime Environment).
Use change button to continue program in other location Select next button to continue. After java
installation Android SDK tools setup wizard automatically resumes.
If java is already installed before beginning with Android SDK installation, wizard deletes its
presence and displays version number of JDK on your machine.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Select next button, you get dialog box asking you to choose users, for which Android SDK is being
installed.
1. Install for anyone using this computer.
2. Install just for me.
Select install for anyone using this computer option and click next. Next dialog prompts you for location
to install Android SDK Tools.
Dialog box also displays default directory location for installing Android SDK tools as c:\Program
Files\Android\android-sdk which can change by selecting Browse button. Select next button to
continue.
Next dialog box asks you to specify start menu folder where you want the program’s short cuts to
appear as bellow.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Default folder name appears called Android SDK Tool. If you don’t want to make start menu folder,
select do not create short cuts check box. Select install button to begin installation of Android SDK
tools.
After installation, select net button, next dialog box tells you android SDK tools setup wizard
completed. Select finish to exit wizard.
Note that check box start SDK manager (to download system images) is checked by default it means
after finish clicked, Android SDK manager was launched.
Android SDK manager shows list of packages and their installation status. Dialog box shows Android
SDK tools package is already installed on machine.
Android SDK manager recommends platform by checking Android 4.1(API 16) and Google USB
driver package by default.
You can check more packages and uncheck existing packages to determine which API you want to
install. Select all packages listed under Extras and click install button to initiate installation.
Next dialog box shows list of packages that you have selected to install. You need to select accept
option followed by install button to begin installation
Android SDK manger log window appears showing downloading and installation progress. It also
shows list of Packages that have been loaded.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
After select close button, next dialog box is android SDK manger Shown below.
Dialog box conform that android SDK platform tools, android4.1 (API16) and its components have
been successfully installed. You do not need android SDK manager now, so you close it.
Android application is combination of several small components include java files, XML resource
and layout files, Manifest files and much more.
It is very time consuming to create all components manually. so, you can use following applications
to help you:
1. Eclipse IDE:
An IDE that makes task of creating java applications easy.
It provides complete platform for developing java applications with compiling, debugging and
testing support.
2. Android development tools (ADT) plug in:
Plug in that added to eclipse IDE and automatically creates necessary android files so you can
concentrate on process of application development.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
NOTE: Before you begin the installation of eclipse IDE, first set path of JDK (My Computer →
Properties→ Advanced tab →Environment variables→ System variables→ path (add path of JDK)
Installing Eclipse:
Eclipse IDE is Multilanguage software developing platform used for developing java applications.
Eclipse can be downloaded from following URL:http://www.eclipse.org/downloads/. Eclipse classic
and eclipse IDE for developers are recommended. Both JDK and eclipse must be same version either
32 bit or 64 bit.
Eclipse is self contained executable files (to install it, eclipse is unzip to any desired folder).
To launch eclipse, run eclipse.exe file. Eclipse IDE starts by displaying logo followed by workspace
launcher dialog box.
Workspace launcher dialog prompts for location of workspace folder where eclipse project files will
store and it can be change by browse button.
Select Ok button to continue when eclipse finishes loading an eclipse welcome screen is displayed.
Select the curved-arrow icon at the top right of screen to go to workbench. You can see that all windows
in workbench (Package Explorer, Edit Window, Debug Window and Task List) are blank at moment.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
These windows update their content as you develop android applications. Next step is installing
android development tools (ADT) plug-in.
Enter name of repository in name textbox and in location box specify location of repository as
https://dl.ssl.google.com/android/eclipse/ and Click ok.
Eclipse accesses List of developers tools available at specified site and display it as shown below.
You can see developer Tools with four child node: Android DDMS, Android Development Tools,
Android Hierarchy Viewer and Android Traceview.
To install all above tools Select Parent node developer Tools and Select Next Button.
You see dialog box to Review Licences for ADT. Read license agreement. Select I accept terms as
agreement Radio Button if you agree with terms and conditions and select finish Button.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
ADT plug in is then downloaded and installed in eclipse after that you get software updates dialog
box asking to restart Eclipse.
Select Restart now Button from Software updates dialog box to make installation changes can take
effect.
On specifying path, list of SDK targets is displayed .You can now develop and test Android
application against any of displayed targets.
You need to select apply and click OK to reload SDK targets and close preference window. Now
eclipse has ADT plug in attached.
Dialog box displays list of existing AVDs else you create new AVDs and manage existing AVDs
Select Create button to define new AVD dialog box. The fields are as follows:
In the Application Name box, enter the name of the application (HelloWorldApp). The project Name
box shows the name of the project automatically by default as application name box.
The Package name box shows the default package name, com.example.helloworldapp. it is unique
identifier, package name may contain uppercase or lowercase letters, numbers, underscores and
package begin with letters.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
From the Build SDK drop-down, select the version of Android most commonly used by your target
audience. Select the Android 4.1 (API 16) as the target platform.
From the Minimum Required SDK select the minimum version of the Android platform that is
required to run application.
Select the Create Project in Workspace check box. By default, the location is set to the workspace
specified when opening Eclipse for the first time.
After Clicking next, configure Launcher Icon is used for configuring the icon for the application. The
dialog shows three options — Image, Clipart and Text — to define icon for our application.
Clipart - It is selected by default showing one of the built-in clipart. Select the Choose
button to open the list of available cliparts.
Image - It is used to specify custom image as our application’s icon.
Text - It displays a text box where we can enter to represent our application. Select the
font button to change the font size and style.
Select Trim Surrounding Blank Space check box to remove the extra blank space around the chosen
image, clipart, or the text. A scroll-bar is also provided to specify padding around the icon.
The icon can be set to appear at the center of assigned space or can be cropped to accommodate the
assigned space. It also has buttons to make the icon appear as square or circle shape.
Other two buttons, Background Colour and Foreground Colour, are provided different colours of the
icon. After defining the icon, click next.
The next dialog prompts us to select whether we want to create an activity. To create activity, dialog
box asks whether we want to create a Blank Activity or Master Detail Flow activity.
The Blank Activity option creates a new blank activity, whereas the Master Detail Flow option creates
two master and detail fragments and two activities.
Select the Create Activity check box and the Blank activity option from the list and then click next.
Next dialog confirms the creation of the activity. The Android SDK assigns the default name Main
Activity to the newly created activity.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Layout file is assigned to the default name as activity_main. Title assigned to the activity by default is
Main activity. If you want to change name remove default name and enter new name.
Finally create the application by clicking Finish. After
application creation Package Explorer shows the files
automatically created by the ADT plug-in, as shown.
Now, we concentrate on the two files that play important
roles in all android applications:
1. The XML file, found in the res/layout folder – It
defines the user interface of the application. It contains
controls such as text view, Button and Checkbox that are
arranged on the display.
2. The java file, found in the src folder – It contains
action code of the controls defined in xml file. Data entered
by the user is fetched and processed with this javafile.
Idea for separating the user interface from the action code
is to isolate the presentation layer from the business logic,it
allows developers to change the user interface without
rewriting the code itself.
I frequently use several terms in xml and java files described in Table shown below
Term Description
Views are user interface (UI) controls that collectively make up the Screen of
View application. TextView, Buttons and edit text controls are all individually known as
views. Views are placed in containers known as layouts.
ViewGroups are extensions of the view class that can contain multiple Child views.
ViewGroup Examples of ViewGroup include LinearLayout, AbsoluteLayout, TableLayout,
RelativeLayout, FrameLayout and ScrollView.
Android applications must have at least one activity. Activity represents single screen
in an application and consists of one or more views. If more than one activity in the
Activity
application, they work independently..Activities in android are usually started with
an internet.
There are two tabs at the bottom of the panel: Graphical Layout and activity_hello_world _app.xml.
The Graphical Layout tab shows the layout in the Eclipse’s visual Designer and the
activity_hello_world_app.xml tab shows the xml code of the layout file.
RelativeLayout is the default layout and arranges the controls in relation to the existing controls.
xmlns:android defines Android namespace. It always set to http://schemas.android.com/apk/res/
android. Namespaces are for assigning unique identifications to application elements to avoiding any
collisions between element names.
Most basic UI control, TextView, which is commonly used for displaying information. In android, the
control that shows upon screen and is used for displaying information and handling events is known
as a Views. All Views are placed inside container.
The most common attributes required for laying out a screen view are Layout_width and
Layout_height. These attributes are also known as LayoutParams in the Android SDK. These indicate
height and width of view.
The two most common values for layout_width and layout_height are match_parent and wrap_content
constants.
match_parent - It fill as much space as possible on the screen based on the available space of
parent layout .
wrap_content - It take as much space as needed to show the View.
If you don’t provide values for these attributes, the Android applications will crash when rendering
the view.
Value of the attributes android:layout_centerHorizantal and android: layout_centerVertical are set to
“true” to make the TextView controls text appear at the horizontal and vertical center of view .
TextView control must be fetched from the strings resource files, strings.xml, defines in res/values
folder. The text hello in the strings.xml file is assigned to the TextView for display.
Package com.androidunleashed.helloworldapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class HelloWorldAppActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_world_app);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_hello_world_app, menu);
return true;
}
}
The Java file is created and maintained in the package com.androidunleashed.helloworldapp that
defined at the time of creation of application.
The file imports the desired class files and also inherits the Activity class. The onCreate() method is
invoked when the Activity is started.
Parameter Bundle saved Instance State refers to a bundle used to pass information between different
activities. If you don’t write super.onCreate() statement into the java file, you get a runtime exception.
It is needed for activity initialization.
User interface defined in the layout file activity_ hello_ world_app.xml is set as the content of an
activity file. The parameter R. layout. activity_ hello_ world_ app in the setContent() method refers to
the activity_hello_world_app.xml file of the project’s res/layout folder.
The character R in the parameter refers to the auto-generated R.java class file. onCreateOptionsMenu
() method dealing with menus.
Let’s keep the existing default code of activity_hello_world_app.xml and HelloWorldApp-
Activity.Java and run the application to see the output.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
To run the application, you need to create an Eclipse launch configuration and choose a virtual device
on which to run the application.
The Android ADT provides two options for creating launch configurations:
1. Run configuration- Used to run an application on a given device.
2. Debug configuration- Used to debug an application while it’s running on a given device.
To create an Eclipse launch configuration, select the Run, Debug configurations option. A Debug
configurations dialog box opens. Double-click the Android Application.
Wizard inserts new configuration named New_configuration shown below let’s rename the
configuration to HelloWorldApp_configuration. You need to specify the Android project name in the
project box.
From the Launch drop-down list in the Launch Action Section, Select the activity file
com.Androidunleashed.helloworldapp. HelloWorldAppActivity option, followed by the Apply button.
Next, you need to define a device on which to run the application. Select the Target tab in the same
dialog box. You get the below Screen.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
The Deployment Target Selection Mode displays the following three options:
1. Always prompt to pick device – Allows you to choose the device or AVD to connect to when
using this launch configuration.
2. Launch on all compatible devices/AVDs – Deploys the application automatically on all the
compatible AVDs or devices available.
3. Automatically pick compatible device – Deploys the application on the AVDs that are selected.
If none of the AVDs are selected, the application is launched on the compatible AVDs or devices
available.
Select the third option, followed by selecting the demoAVD check box to test the application against
the Android 4.1 target.
After Selecting the AVD, Select the Apply button, followed by close button to save the launch
configuration file.
To unlock the Home screen, either select the Menu button on the emulator, press the f2 key on your
computer, or drag the lock to the right .After the emulator is unlocked, the Home screen appears,
followed by the output of the application as shown in below
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
You can see that then applications title, HelloWorld, appears in the title bar of the emulator, and a
text message, Hello world, and is displays via the Text view control.
The output of the application confirms that the activity is running correctly in the emulator.
If you feel that the screen shown by the emulator is too big, you can reduce it to the actual size by
selecting the window, AVD manager option.
Android Device Manager Dialog box opens up, select demo AVD and click the start button. Select
the Scale to real size check box and then click the Launch button to start the emulator.
Don not close the emulator screen; let it stay active to save the emulator’s loading time for running
other applications.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
The Dalvik Virtual Machine (Dalvik VM):
While running Android applications, the android runtime provides the Dalvik virtual machine that
provides an environment to deploy and run Android applications.
Dalvik VM is the androids platform virtual machine written by Dan Bornstein. It is specifically
designed Virtual Machine for android and optimized for mobile devices with limited battery, memory
and computation capability.
When you run an application, the androids SDK access information in the XML files, converts it into
the java source code and place it the R.java file.
The java code in the R.java class file is compiled into the java byte code files, which, with the help of
a tool named dx, is converted into Dalvik byte code and stored in .dex format.
The Dalvik Executable format is optimized for efficient storage and low memory consumption.
Android applications are not deployed in dex code is bundled into an APK file.
Only android:text statement is modified. Here, Hello World is assign to android:text attribute.
Lets run the application to see the output .The output displays the Text, “Hello World!, that you
assigned to the Text View control.
To make the message “Hello World!”Appear at the top-left control of the screen, remove the two
attributes android: layout_centerHorizontal and android from the android:layout_centerVertical from
the <Text View> tag in above code
Output of application shows text “Hello World” on top left corner of screen
<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">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message"
tools:context=".HelloWorldAppActivity"/>
</RelativeLayout>
After assign ID to TextView control, it will be accessible in Activity file. To assign text to TextView
control through HelloWorldAppActivity.java, modify it to appear as shown below
Package com.androidunleashed.helloworldapp;
import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
public class HelloWorldAppActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_world_app);
TextView mesg = (TextView) findViewById(R.id.message);
mesg.setText("HelloWorld !");
}
}
Control with the message ID in the layout file by using the findViewById method of the Activity
class and maps it to the TextView object,mesg.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
Assigns the text HelloWorld! To mesg object and hence to the TextView control. We erased the
onCreateOptionsMenu() method because we are not dealing with menus.
On running the application, you see changes. Let’s assign a few more attributes to the TextView
control and change its height, width, color, style, background and alignment.
.
Applying Dimensions to Controls:
Dimensions are commonly used to specify the size and other properties for the controls and layouts.
The following units of measurements are used:
px (pixels)—Corresponds to the actual pixels on the screen.
in (inches)—Based on the actual size of the screen.
mm (millimetres)—Based on actual size of the screen.
pts (points)—Points are a fixed dimension—1/72 of an inch.
dip or dp (device-independent pixels)—Based on the physical density of the screen. This unit is
relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp to pixel.
Example “on a 240 dpi screen, 1dp is equal to 1.5 pixels.”
sp (scale independent pixels)—Similar to the dp unit, but also depends on the user’s font size
settings. Hence this unit is preferred while specifying font sizes.
Let’s apply some of the attributes to the TextView control (in activity_hello_world_app.xml) of the
helloworldapp application, as shown below
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message"
android:typeface="serif"
android:textColor="#0f0"
tools:context=".HelloWorldAppActivity"
android:textSize="25dp"
android:textStyle="italic"
android:gravity="center_horizontal" />
This code makes the text of the TextView control appear in serif font,green color,25dp size,italic and
at the horizontal center of the container
Let’s apply a few more attributes to the TextView control here:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message"
tools:context=".HelloWorldAppActivity"
android:gravity="center"
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
android:height="200dp"
android:width="150dp"
android:typeface="serif"
android:textColor="#0F0"
android:textSize="25dp"
android:textStyle="bold"/>
This code makes the content of the TextView wrap move to the next line if the width assigned to it is
insufficient.
The TextView control is assigned the height and width of 200dp and 150dp and its text is set to
appear at the center of its assigned size.
The text appears in serif font, green color, 25dp font size and bold. The text in the TextView appears
as shown below.
Switching orientations[KEYPAD_7,Ctrl-F11/KEYPAD_9,Ctrl-F12]
You can also interact with an emulator from within the DDMS tool. Eclipse IDE provides three
perspectives to work
The Java Perspective :-
It’s the default perspective in Eclipse where you spend most of the time. It shows the panes
where you can write code and navigate around the project.
The Debug perspective :-
It enables application debugging. You can set breakpoints, step through the code, view
LogCat logging information, threads and so on.
The Dalvik Debug Monitor Service (DDMS) perspective :-
It enables you to monitor and manipulate emulator and device status. It also provides screen
capture and simulates incoming phone calls, SMS sending and GPS coordinates.
You can switch between perspectives by choosing appropriate icon in top right corner of Eclipse
environment
The Android Debug Bridge (ADB):
The android debug bridge (ADB) is a client-server program that is part of the android SDK. It is used
to communicate with, control and manage the android device and emulator.
It consists of three components:
CLIENT --Runs on a computer machine. It can be invoked from the command prompt using
the adb command.
DAEMON --Runs as a background process in either an emulator instances or in device itself.
SERVER --Runs in a computer machine in the background. It manages the communication
between the client and the daemon.
III.BTECH II-SEM AI&IOT: MOBILE APPLICATION DEVELOPMENT
When you install the android SDK, the Android Debug Bridge is also automatically installed along
with it. When ADB is activating, you can issue adb commands to interact with one or more emulator
instances.
Using the shell command, you can perform several tasks such as listing existing applications, deleting
applications, and querying or modifying SQLite database on device.
To access ADB through windows, open the command prompt and navigate to the folder where adb.exe
is located by using the cd command.
By default, adb.exe is installed in C:\program files(x86)\Android-sdk\platform-tools. After finding
adb, you can issue the following commands to interact with the device or emulator:
adb devices --- Displays the list of devices attached to the computer currently on your computer,
emulator-5554.
adb push --- Copies files from your computer to the device /emulator.
Syntax :- adb push source destination
Where source to the file along with its path that you want to copy, destination refers to the device or
emulator where you want to copy the file.
adb pull --- Copies files from the device/emulator to your computer.
Syntax:- adb pull source(destination)
adb shell --- Display the shell prompt where can issue Unix commands.
You can see the names of different files and folders of the emulator after issue ls a command.You can
the commands to list, rename, and delete applications from the emulator For example, to delete thefile
song 1.mp3 that you pushed into the emulator, you issue the rm command. To leave Shell; Press Ctrl+d.
adb install --- Install an application from your computer to the device/emulator.
Syntax:- adb install appname.apk
This Code C:\program Files(x860\Android\android-sdk\platform-tools>adb install D:\ androidun
leashed\loginApp.apk. Installs the application package file loginApp.apk into the emulator.
IV.BTECH I-SEM, CSE: MOBILE APPLICATION DEVELOPMENT
Launching Android application on hand set:
To load application on real hand set, you need to plug handset into your computer, using USB cable.
You first confirm whether configurations for debugging your application are correct or not and launch
application as shown below
1. In eclipse ,choose Run , Debug configuration option
2. Select configuration Helloworld_cofiguration. which you created for helloworld application
3. Select target tab, set deployment target selection Mode to Manual. Manual option allows us to
choose device or AVD to connect to when using this configuration
4. Apply changes to configuration file by clicking Apply button
5. Plug an Android device into computer, using USB cable
6. Select Run, Debug in Eclipse or Press F11 key. Dialog box appears, showing all available
configurations for running and debugging your application. Physical device connected to computer
are also listed. Double click running android device. Eclipse now installs android application on
handset, attaches debugger and runs the application