0% found this document useful (0 votes)
3 views

Merged Android App.devp't (1)

The document provides an overview of Android, detailing its architecture, development environment, and core components. It covers the history of Android, the Open Handset Alliance, features, categories of applications, and the process of setting up an Android development environment using Eclipse. Additionally, it explains the creation of Android applications, including the implementation of menus and user interactions.

Uploaded by

Shafi Esa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Merged Android App.devp't (1)

The document provides an overview of Android, detailing its architecture, development environment, and core components. It covers the history of Android, the Open Handset Alliance, features, categories of applications, and the process of setting up an Android development environment using Eclipse. Additionally, it explains the creation of Android applications, including the implementation of menus and user interactions.

Uploaded by

Shafi Esa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

MOBILE APPLICATION

DEVELOPMENT

BY Sisay A.(MSc)
What is Android
• Android is a complete set of software for mobile devices such as
tablet computers, notebooks, smartphones, electronic book readers,
set-top boxes etc.
• It contains a linux-based Operating System, middleware and key
mobile applications.
• It can be thought of as a mobile operating system.
• But it is not limited to mobile only. It is currently used in various
devices such as mobiles, tablets, televisions etc.
• Android is a software package and linux based operating
system for mobile devices such as tablet computers and
smartphones.
• It is developed by Google and later the OHA (Open Handset
Alliance).
• Java language is mainly used to write the android code even
though other languages can be used.
• The goal of android project is to create a successful real-
world product that improves the mobile experience for end
users.
What is Open Handset Alliance (OHA)
• It's a consortium of 84 companies such as google, samsung,
AKM, synaptics, KDDI, Garmin, Teleca, Ebay, Intel etc.

• It was established on 5th November, 2007, led by Google.


• It is committed to advance open standards, provide services
and deploy handsets using the Android Plateform.
Features of Android
• The important features of android are given below:
• It is open-source.
• Anyone can customize the Android Platform.
• There are a lot of mobile applications that can be chosen by
the Consumer.
• It provides many interesting features like weather details,
opening screen, live RSS (Really Simple Syndication) feeds etc.
• It provides support for messaging services(SMS and MMS),
web browser, storage (SQLite), connectivity (GSM, CDMA,
Blue Tooth, Wi-Fi etc.), media, handset layout etc.
Categories of Android applications
• There are many android applications in the market. The top
categories are:
• Entertainment
• Tools
• Communication
• Productivity
• Personalization
• Music and Audio
• Social
• Media and Video
• Travel and Local etc.
History of Android
• Initially, Andy Rubin founded Android Incorporation in Palo Alto, California,
United States in October, 2003.
• In 17th August 2005, Google acquired android Incorporation. Since then, it
is in the subsidiary of Google Incorporation.
• The key employees of Android Incorporation are Andy Rubin, Rich
Miner, Chris White and Nick Sears.
• Originally intended for camera but shifted to smart phones later because of
low market for camera only.
• Android is the nick name of Andy Rubin given by coworkers because of his
love to robots.
• In 2007, Google announces the development of android OS.
• In 2008, HTC launched the first android mobile.
Android
Versions,
Codename
and API
Android Architecture
• Android architecture or Android software stack is
categorized into five parts:
• Linux kernel
• Native libraries (middleware),
• Android Runtime
• Application Framework
• Applications
Android
Architecture
Cont'd...
1. Linux kernel
• It is the heart of android architecture that exists at the root of
android architecture. Linux kernel is responsible for device drivers,
power management, memory management, device management
and resource access.
2. Native Libraries
• On the top of linux kernel, their are Native libraries such as
WebKit, OpenGL, FreeType, SQLite, Media, C runtime library (libc)
etc.
• The WebKit library is responsible for browser support, SQLite is for
database, FreeType for font support, Media for playing and
recording audio and video formats.
Cont'd...
3. Android Runtime
• In android runtime, there are core libraries and DVM (Dalvik Virtual Machine)
which is responsible to run android application.
• DVM is like JVM but it is optimized for mobile devices. It consumes less
memory and provides fast performance.
4. Android Framework
• On the top of Native libraries and android runtime, there is android
framework.
• Android framework includes Android API's such as UI (User Interface),
telephony, resources, locations, Content Providers (data) and package
managers.
• It provides a lot of classes and interfaces for android application
development.
Cont'd...
5. Applications
• On the top of android framework, there are applications.
• All applications such as home, contact, settings, games, browsers
are using android framework that uses android runtime and
libraries.
• Android runtime and native libraries are using linux kernal.
Android Core Building Blocks
• An android component is simply a piece of
code that has a well defined life cycle
e.g. Activity, Receiver, Service etc.

• The core building blocks or fundamental


components of android are activities, views,
intents, services, content providers,
fragments and AndroidManifest.xml.
Cont'd...
• Activity
• An activity is a class that represents a single screen. It is like a
Frame in AWT.
• View
• A view is the UI element such as button, label, text field etc.
Anything that you see is a view.
• Intent
• Intent is used to invoke components. It is mainly used to:
• Start the service Launch an activity
• Display a web page Display a list of contacts
• Dial a phone call etc. Broadcast a message
Cont'd...
• Service
• Service is a background process that can run for a long time.
• There are two types of services local and remote. Local service is
accessed from within the application whereas remote service is
accessed remotely from other applications running on the same
device.
• Content Provider
• Content Providers are used to share data between the
applications.
• Fragment
• Fragments are like parts of activity. An activity can display one or
more fragments on the screen at the same time.
Cont'd...
• AndroidManifest.xml
• It contains information about activities, content providers,
permissions etc.
• It is like the web.xml file in Java EE.
• Android Virtual Device (AVD)
• It is used to test the android application without the need for
mobile or tablet etc.
• It can be created in different configurations to emulate different
types of real devices.
Android Emulator

• The Android emulator is an Android Virtual Device (AVD), which


represents a specific Android device.
• We can use the Android emulator as a target device to execute and
test our Android application on our PC.
• The Android emulator provides almost all the functionality of a real
device.
• We can get the incoming phone calls and text messages. It also gives
the location of the device and simulates different network speeds.
• Android emulator simulates rotation and other hardware sensors and
much more
Requirement and recommendations
• The Android emulator takes additional requirements beyond the
basic system requirement for Android Studio.
• These requirements are given below:
• SDK Tools 26.1.1 or higher
• 64-bit processor
• Windows: CPU with UG (unrestricted guest) support
• HAXM 6.2.1 or later (recommended HAXM 7.2.0 or later)
How to setup Android for Eclipse IDE
• Software required to setup android for eclipse IDE manually.
• Install the JDK
• Download and install the Eclipse for developing android application
• Download and Install the android SDK
• Install the ADT plugin for eclipse
• Configure the ADT plugin
• Create the AVD
• Create the hello android application
• 1) Install the Java Development Kit (JDK)
• 2) Download and install the Eclipse IDE
• 3) Download and install the android SDK
• 4) Download the ADT plugin for eclipse
• ADT (Android Development Tools) is required for developing the android
application in the eclipse IDE.
• For downloading the ADT, you need to follow these steps:
• Start the eclipse IDE, then select Help > Install new software...
• In the work with combo box,
write https://dlssl.google.com/android/eclipse/
• select the checkbox next to Developer Tools and click next
• You will see, a list of tools to be downloaded here, click next
• click finish
• After completing the installation, restart the eclipse IDE
• 5) Configuring the ADT plugin
• After the installing ADT plugin, now tell the eclipse IDE for your
android SDK location. To do so:
• Select the Window menu > preferences
• Now select the android from the left panel. Here you may see a dialog box
asking if you want to send the statistics to the google. Click proceed.
• Click on the browse button and locate your SDK directory e.g. my SDK location
is C:\Program Files\Android\android-sdk .
• Click the apply button then OK.
• 6) Create an Android Virtual Device (AVD)
• For running the android application in the Android Emulator, you
need to create and AVD. For creating the AVD:
• Select the Window menu > AVD Manager
• Click on the new button, to create the AVD
• Now a dialog appears, write the AVD name e.g. myavd. Now choose the target
android version e.g. android4.0.
• click the create AVD
• 7) create and run the simple android application
End of Topic #1
Topic #2
Notification, Menus and Dialogs
Creating your First Android Application
• Using Eclipse, create a new project by selecting File->New -> Android
Application Project

• Name the Android project as shown here


• Click Next
• Select the launcher icon and click next

• Select Blank Activity ,Click Next and then Finish


How It Works
• To create an Android project using Eclipse, you need to supply the
following information
Anatomy of an Android Application
• The various folders and their files are as
follows:
• src — Contains the .java source files for your
project. In this example, there is one file,
MainActivity.java. The MainActivity.java file is
the source file for your activity. You will write
the code for your application in this file.
• Android 4.4.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 project.
• You should not modify this file
Anatomy of an Android Application
• assets – This folder contains all the assets
used by your application, such as HTML,
text file, databases etc.
• res – This folder contains all the resources
used in your application. It also contains a
few other subfolders: layout, values.
• AndroidManifest.xml – This is the
manifest file for your Android Application.
Here you specify the permissions needed
by your application as well as other
features.
Anatomy of an Android Application
• The activity_main.xml file defines the user interface for your activity.
• The AndroidManifest.xml file contains detailed information about the
application:
It defines the package name of the application as
net.learn2develop.HelloWorld
The version code of the application is 1. This value is used to identify the
version number of your application.
The application uses the image named icon.png located in the drawable
folder.
Build, Install, and Run Android
Application in Your Emulator or Device
Topic #3
Implementing an Options Menu
• In Android apps, you can make use of three standard menus supported
within the platform:
• the context menu,
• the options menu, and
• submenus.
• The options menu appears when the user presses the menu button on
their Android device.
• This is a common feature in almost all apps, so your users will be used
to the menu appearing in this way.
• The options menu is typically used for providing additional info about
an app, as well as linking to a help and settings sections.
• To implement an options menu for an Activity in an Android app, a few
fairly straightforward steps are required.
Step 1: Open an Activity Class
• The options menu you create will work with one or more Activity
classes, so choose an Activity and open it in Eclipse.
• If your app only has one Activity class as its main screen, you can use
it. If you want to create a new Activity:
• Select your application package and choose "File", "New", then
"Class" and enter a name of your choice.
• Remember to make your class extend the Activity class and add it to
the application Manifest.
Step 2: Create a Resources Folder
• If you look at your application project in the Eclipse Package Explorer,
you will see the various files and directories within it.
• The "res" folder holds all of your application resources. To create a
menu, you need a menu folder, so create one inside the "res" folder
by selecting it and choosing "File", "New", then "Folder" and entering
"menu" as the name.
Step 3: Create a Menu XML File
• Your options menu will be defined as an XML file inside the new
menu folder you created.
• Choose the folder and create a new file by selecting "File", "New",
then "File" and entering a name.
• You can choose any filename you like, for example
"my_options_menu.xml".
• Eclipse will display error messages when you first create the menu file,
but don't worry, these will disappear as you build it.
• Open your new XML file and enter the following outline:
Step 4: Add Items to Your Menu
• You can add one or more items to your options menu depending on the
needs of your project.
• Add an item for each menu option using the following syntax:

• This defines two menu items, one for an "About" section and one for
"Help" information.
Step 5: Inflate Your Menu Resource
• To instruct Android to use your options menu, open the Activity class
you want it to appear with.
• Add the following method to your Java code, inside the class
declaration and after the "onCreate" method:

• Edit the "my_options_menu" section if you saved your menu XML file
with a different name.
Step 6: Detect User Interaction
• To respond to user interaction with your menu, you first need to detect it
within your Activity class.
• Add the following method outline after the "onCreateOptionsMenu"
method:

• Inside this method, which returns a boolean value, you can add code to
respond to each particular item. The system will automatically call the
"onOptionsItemSelected" method when the user chooses any of the
options menu items.
Step 7: Respond to Menu Item Selection
• Before your code can respond appropriately to user interaction with the
menu, you need to work out which item was selected.
• Add a switch statement to your method using the following sample syntax:

• Add a case statement for each item in your menu. This sample code starts
new Activity screens for each item chosen. If you opt to do this, you will
need to add an Activity class for each option in your application Java code
as well as in the Manifest file.

You might also like