0% found this document useful (0 votes)
52 views34 pages

Mad U-1

The document provides an overview of mobile application development, focusing on Android as the most popular mobile operating system. It details the architecture of Android, its various versions, features, and the role of the Open Handset Alliance in its development. Additionally, it discusses the Integrated Development Environment (IDE) Android Studio, highlighting its features, advantages, and system requirements for app development.

Uploaded by

lavanya naren007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views34 pages

Mad U-1

The document provides an overview of mobile application development, focusing on Android as the most popular mobile operating system. It details the architecture of Android, its various versions, features, and the role of the Open Handset Alliance in its development. Additionally, it discusses the Integrated Development Environment (IDE) Android Studio, highlighting its features, advantages, and system requirements for app development.

Uploaded by

lavanya naren007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

MOBILE APPLICATION DEVELOPMENT

INTRODUCTION

 A Mobile application most commonly referred to as an app, is a type application software designed
to run on a mobile device such as smart phone, tablet computer.
 Mobile app development is the process by which a mobile application is developed for mobile
devices like PDAs, Tablet computer or mobile phones.
 Andorid is a mobile operating system developed by Google based on a modified version of Linux
kernel and open source software which is designed for touchscreen mobile devices such as smart
phones and tablets.
 Most mobile applications are developed for two main smartphone platforms,
1. Android operating system
2. Apple’s iOS
 Android is the world’s most popular platform for mobile devices.
 For Application developers, Android is an open platform that provides exciting opportunities for
developing virtually any app imaginable.
 Android applications can be packaged easily and sold out either through a store as Google play
Store, Windows Phone Store, Slide Me, Opera Mobile Store, Mobango, F-droid and the Amazon
App Store.

ANDROID

 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.
 Now a days, most popular used mobile operating system (OS) is Android.
 Android was founded in Palo Alto of California, U.S. by Andy Rubin, Rich Miner, Nick Sears and
Chris White during 2003. After it was acquired by Google in 2005.
 The Android is a powerful Operating system OS and it supports large number of applications (apps)
in smart phones. These applications are more comfortable and advanced for the users. The hardware
that supports android software is based on ARM(Advanced RISC machine) architecture platform.
 The Android is an open source operating system means that it is free and any one can use it.
 It is available low cost in the market
 The Android development supports with the full java pragramming language.
 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.

OPEN HANDSET ALLIANCE(OHA)

 The Open Handset Alliance (OHA) is a business alliance that was created for the purpose of
developing open mobile device standards.
 In August 2005, Google formed Open Handset Alliance (OHA) in order to develop an open source
software platform for use in mobile devices.
 The OHA is the group that is in charge of the Android smart phones operating system.
 The OHA has approximately 80 member companies, including HTC, Dell, Intel, Motorola, LG
Electronics, Samsung, Qualcomm and Google.
 The OHA’s main product is the Android platform – the world’s most popular smartphone platform.
 The members of OHA include handset manufactures, chip makers, commercialization companies,
software companies and mobile operators/ users.
 The goal of the open handset alliance(OHA) is to providing users with the service and applications
that they want and need.

ANDROID VERSIONS
The development of the Android operating system was started in 2003 by Android, Inc. Later on, it was
purchased by Google in 2005. The beta version of Android OS was released on November 5, 2007, while
the software development kit (SDK) was released on November 12, 2007.

The first Android mobile was publicly released with Android 1.0 of the T-Mobile G1 (aka HTC Dream) in
October 2008.

The code names of android ranges from A to N currently, such as Aestro, Blender, Cupcake, Donut,
Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwitch, Jelly Bean, KitKat, Lollipop and
Marshmallow.

ANDROID VERSIONS, NAME, AND API LEVEL

Code name Version numbers API level Release date


No codename 1.0 1 September 23, 2008
No codename 1.1 2 February 9, 2009
Cupcake 1.5 3 April 27, 2009
Donut 1.6 4 September 15, 2009
Eclair 2.0 - 2.1 5-7 October 26, 2009
Froyo 2.2 - 2.2.3 8 May 20, 2010
Gingerbread 2.3 - 2.3.7 9 - 10 December 6, 2010
Honeycomb 3.0 - 3.2.6 11 - 13 February 22, 2011
Ice Cream Sandwich 4.0 - 4.0.4 14 - 15 October 18, 2011
Jelly Bean 4.1 - 4.3.1 16 - 18 July 9, 2012
KitKat 4.4 - 4.4.4 19 - 20 October 31, 2013
Lollipop 5.0 - 5.1.1 21- 22 November 12, 2014
Marshmallow 6.0 - 6.0.1 23 October 5, 2015
Nougat 7.0 24 August 22, 2016
Nougat 7.1.0 - 7.1.2 25 October 4, 2016
Oreo 8.0 26 August 21, 2017
Oreo 8.1 27 December 5, 2017
Pie 9.0 28 August 6, 2018
Android 10 10.0 29 September 3, 2019
Android 11 11 30 September 8, 2020

FEATURES OF ANDROID

Android is an open source, lightweight and powerful operating system which supports great features.

S.No. Feature & Description


1 Beautiful UI
Android OS basic screen provides a beautiful and intuitive user interface.
2 Connectivity
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and
WiMAX.
3 Storage
SQLite, a lightweight relational database, is used for data storage purposes.
4 Media support
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3,
MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
5 Messaging
SMS and MMS
6 Web browser
Based on the open-source WebKit layout engine, coupled with Chrome's V8
JavaScript engine supporting HTML5 and CSS3.
7 Multi-touch
Android has native support for multi-touch which was initially made available in
handsets such as the HTC Hero.
8 Multi-tasking
User can jump from one task to another and same time various application can run
simultaneously.
9 Resizable widgets
Widgets are resizable, so users can expand them to show more content or shrink
them to save space.
10 Multi-Language
Supports single direction and bi-directional text.
11 GCM
Google Cloud Messaging (GCM) is a service that lets developers send short message
data to their users on Android devices, without needing a proprietary sync solution.
12 Wi-Fi Direct
A technology that lets apps discover and pair directly, over a high-bandwidth peer-
to-peer connection.
13 Android Beam
A popular NFC-based technology that lets users instantly share, just by touching two
NFC-enabled phones together.

ANDROID ARCHITECTURE

 Android architecture contains a different number of components to support any Android device’s
needs.
 Android software contains an open-source Linux Kernel having a collection of a number of
C/C++ libraries.
 The main components of Android architecture are the following:-
 Applications
 Application Framework
 Android Runtime
 Platform Libraries
 Linux Kernel

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, there are Native libraries such as WebKit, OpenGL used for 2D & 3D
Graphics, FreeType, SQLite, Media, C runtime library (libc) etc.
 WebKit Library for Browser.
 SQLite for Database.
 FreeType for font support.
 Media for playing audio and video formats.

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.
 It consumes less memory & provides fast performance.
DVM:

 Programs are commonly written in java and compiled to bytecode.


 It is then translated to Dalvik byte code (.dex files)
 Set of core libraries which enables android application developers to write android applications
using java.
 javactool compiles the java source file into the class file
 A tool dx is used to convert java class files into the .dex format
 The Android assets packaging tool(aapt) handles the packaging process.

4) Android Framework

 On the top of Native libraries and android runtime, there is android framework.
 The Application Framework layer provides many higher-level services to applications in the
form of Java classes.
 Application developers are allowed to make use of these services in their applications.
 Android framework includes Android API's such as UI (User Interface), telephony, resources,
locations, Content Providers (data) and package managers.

Activity Manager − Controls all aspects of the application lifecycle and activity stack.

Content Providers − Allows applications to publish and share data with other applications.

Resource Manager − Provides access to non-code embedded resources such as strings, color
settings and user interface layouts.

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) Android Applications

 Applications is the top layer of android architecture, the pre-installed applications like home,
contacts, camera, gallery etc.., and third party applications downloaded from play store like chat
applications, games etc.., will be installed on this layer only.
 It runs within the Android runtime with the help of the classes and services provided by the
Application Framework.
Android Debug Bridge:

 Android Debug Bridge (ADB) is a command-line tool built into Android’s SDK.
 It lets you communicate with a device and perform various actions, such as installing and
debugging apps, copying files back and forth, and accessing Unix shell to run commands.
 ADB is a client-server program that includes three components:
Client:
 The client runs ADB commands from a shell or script on your development Machine. Its role is
to send commands to the server.
Daemon(adbd):
 The ADB daemon, called adbd.
 The daemon runs as a background process on your device. Its purpose is to connect with the
ADB server through USB or TCP for emulators. The ADB server considers a device “ONLINE”
when it successfully connects with the daemon.
Server:
 The server runs as a background process on your development machine. Its purpose is to sense
the USB port when you attach or remove the device, maintain a list of connected devices, and
assign different states to each of them like “ONLINE”, “OFFLINE”, “BOOTLOADER” and
“RECOVERY”.

IDE (INTEGRATED DEVELOPMENT ENVIRONMENT)

 An IDE is a software development tool that is mainly used by the developers to write and test the
programs or software.
 Android Studio is the official Integrated Development Environment (IDE) for Android app
development.
 A mobile IDE offers a platform that combines code editing, debugging, testing, and deployment
tools, enabling developers to build mobile applications efficiently.

Features of IDE:

1. Android-specific Features: Android Studio is specifically designed for Android


development, providing features like XML layout design, APK analyzer, and tools for
debugging and performance profiling.
2. Gradle Integration: Android Studio uses Gradle as its build system, which simplifies
dependency management and allows customization of the build process.
3. Emulator: It includes an Android emulator to test applications on virtual devices with
different Android versions and configurations.
4. Google Integration: Since Android Studio is developed by Google, it integrates well with
other Google services and APIs, such as Firebase for backend services.
5. Continuous Updates: Android Studio receives frequent updates, ensuring compatibility
with the latest Android SDK versions and incorporating new features and improvements.
6. Community and Support: Being the standard IDE for Android, it has a large community of
developers, which means sample resources, tutorials, and community supports are
available.

Properties of IDE:

 Code Editor: IDEs provide a code editor with features like syntax highlighting, auto-
completion, code formatting. These features help developers write code faster and with fewer
errors.
 Build Automation: IDEs automate the build process, allowing developers to compile, build, and
package their applications with ease. Build tools integrated into IDEs (such as Gradle or Maven)
 Debugger: This helps in identifying and fixing bugs efficiently.
 Version Control Integration: They provide tools for committing changes, viewing version
history, resolving conflicts, and merging branches directly within the IDE.
 Project Management: IDEs support project management features such as project templates, file
organization, and project navigation, to visualize the project structure and manage files.
 Code Templates and Snippets: IDEs provide pre-defined code templates and snippets that help
developers quickly insert commonly used code patterns and structures.
 Language Support: IDEs are designed to support specific programming languages and
frameworks.
 User Interface Design Tools: For platform-specific development like Android or desktop
applications, IDEs often include visual designers for creating user interfaces (UIs) using drag-
and-drop components. These tools generate XML or code for UI layout.
 Error Checking and Code Analysis: IDEs perform real-time error checking and code analysis
to highlight syntax errors, potential bugs, and code style violations as developers write code.
 Integration with External Services: Modern IDEs integrate with external services such as
cloud platforms (e.g., AWS, Azure), databases, and APIs.

Advantages of using IDEs:

 Reformat coding.
 Check matching braces.
 Single step through a function.
 Traverse a package hierarchy searching for all the instances of a specific string.
 Helps in generating the UML diagram.

Some of the best IDEs:

 Eclipse- particularly for Java.


 Visual Studio- for programming languages like C, C++, C#.
 Android Studio- particularly for Android Java.
 Pycharm- Particularly for Python.
 RubyMine-Particularly for ruby on rails.

Android Studio and Its Working Environment:

Step 1 - System Requirements

You can start your Android application development on either of the following operating systems −

Microsoft® Windows® 10/8/7/Vista/2003 (32 or 64-bit)

Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)

Second point is that all the required tools to develop Android applications are open source and can be
downloaded from the Web.
Java JDK5 or later version

Java Runtime Environment (JRE) 6

Android Studio

Step 2 - Setup Android Studio

Android Studio is the official IDE for android application development.

If you are installing Android Studio on Mac or Linux, You can download the latest version
from Android Studio Mac Download,or Android Studio Linux Download, check the instructions
provided along with the downloaded file for Mac OS and Linux.

Installation

So let's launch Android Studio.exe, Make sure before launch Android Studio, Our Machine should
required installed Java JDK.

Once you launched Android Studio, its time to mention JDK7 path or later version in android studio
installer.
Below the image initiating JDK to android SDK
Need to check the components, which are required to create applications, below the image has
selected Android Studio, Android SDK, Android Virtual Machine and performance(Intel chip).

Need to specify the location of local machine path for Android studio and Android SDK.
Need to specify the ram space for Android emulator by default it would take 512MB of local machine
RAM.

At final stage, it would extract SDK packages into our local machine, it would take a while time to
finish the task and would take 2626MB of Hard disk space.
Below are the steps to start and set up a new android project in Android Studio.

Select the first option to start a new android project.

Then, name your application in the ‘Application name‘ Text box.


By default, the application name appears as “MyApplication”. Click on “Next” after filling the
Application name field, leaving the other fields to their default values.

Then select the Minimum SDK to select the operating system which must be least version to run your
app, here “Jelly Bean” is made Minimum SDK, and phones and tablets with versions lower to this OS
will not be able to run your apps. Click on “Next”
The next step is to choose the Activity to mobile. Activity in Android refers to asingle screen
with a user interface. For Beginners, “Empty Activity” is recommended.

Then, fill the Activity name text field. By default, “MainActivity” is filled in this text box as the name
of your activity. In android studio, files are usually named in camel case. An xml file of the activity is
created using the first word in the Activity name. An xml file is a file to provide functionalities of user
interface for our app.
Click on “Finish”.
Then, a default app is created with all default files. And you can now start writing the application
code.

Create Android Virtual Device

To test your Android applications, you will need a virtual Android device. So before we start
writing our code, let us create an Android virtual device. Launch Android AVD Manager Clicking
AVD_Manager icon as shown below.
After Click on a virtual device icon, it going to be shown by default virtual devices which are
present on your SDK, or else need to create a virtual device by clicking Create new Virtual
device button

If your AVD is created successfully it means your environment is ready for Android application
development.

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. It accesses the Google
Play store, and much more.
Requirement and recommendations:

The Android emulator takes additional requirements


beyond the basic system requirement for Android Studio.
These requirements are,

 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)

Install the emulator:

The Android emulator is installed while installing the


Android Studio. However some components of emulator
may or may not be installed while installing Android
Studio. To install the emulator component, select
the Android Emulator component in the SDK Tools tab of
the SDK Manager.

Run an Android app on the Emulator:

To start the Android Emulator and run an application in our project:

1. In Android Studio, we need to create an Android Virtual Device (AVD) that the emulator can
use to install and run your app. To create a new AVD:-

1.1 Open the AVD Manager by clicking Tools > AVD Manager.

1.2 Click on Create Virtual Device, at the bottom of the AVD Manager dialog. Then Select
Hardware page appears.
1.3 Select a hardware profile and then click Next. If we don?t see the hardware profile we want,
then we can create or import a hardware profile. The System Image page appears.

1.4 Select the system image for the particular API level and click Next. This leads to open a Verify
Configuration page.
1.5 Change AVD properties if needed, and then click Finish.

2. In the toolbar, choose the AVD, which we want to run our app from the target device from the
drop-down menu.

3. Click Run.

Launch the Emulator without first running an app

To start the emulator:

 Open the AVD Manager.


 Double-click an AVD, or click Run
XML

 XML stands for eXtensible Markup Language


 XML is a markup language much like HTML used to describe data.
 XML was designed to store and transport data
 The XML language has no predefined tags, we must define our own tags.
 XML is well readable by human and machine.

Basics of User Interface(UI)

UI screen components

A typical user interface of an android application consists of action bar and the application content
area.

 Main Action Bar


 View Control
 Content Area
 Split Action Bar

These components have also been shown in the image below −

A UI is defined in an xml file. During compilation, each element in the XML is compiled into
equivalent Android GUI class with attributes represented by methods.

View and ViewGroups

An activity is consist of views. A view is just a widget that appears on the screen. It could be
button e.t.c. One or more views can be grouped together into one GroupView. Example of
ViewGroup includes layouts.

Types of layout,

There are many types of layout. Some of which are listed below −

 Linear Layout
 Absolute Layout
 Table Layout
 Frame Layout
 Relative Layout

Linear Layout

Linear layout is further divided into horizontal and vertical layout. It means it can arrange views in
a single column or in a single row. Here is the code of linear layout(vertical) that includes a text
view.

<?xml version=”1.0” encoding=”utf-8”?>


<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello” />
</LinearLayout>

Absolute Layout

The Absolute Layout enables you to specify the exact location of its children. It can be declared
like this.

<AbsoluteLayout
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >

<Button
android:layout_width=”188dp”
android:layout_height=”wrap_content”
android:text=”Button”
android:layout_x=”126px”
android:layout_y=”361px” />
</AbsoluteLayout>

TableLayout
The Table Layout groups views into rows and columns. It can be declared like this.

<TableLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_height=”fill_parent”
android:layout_width=”fill_parent” >

<TableRow>
<TextView
android:text=”User Name:”
android:width =”120dp”
/>

<EditText
android:id=”@+id/txtUserName”
android:width=”200dp” />
</TableRow>

</TableLayout>

Relative Layout

The Relative Layout enables you to specify how child views are positioned relative to each other.It
can be declared like this.

<RelativeLayout
android:id=”@+id/RLayout”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >
</RelativeLayout>

Frame Layout

The Frame Layout is a placeholder on screen that you can use to display a single view. It can be
declared like this.

<?xml version=”1.0” encoding=”utf-8”?>


<FrameLayout
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignLeft=”@+id/lblComments”
android:layout_below=”@+id/lblComments”
android:layout_centerHorizontal=”true” >

<ImageView
android:src = “@drawable/droid”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />
</FrameLayout>
Apart form these attributes, there are other attributes that are common in all views and
ViewGroups. They are listed below −

Sr.No View & description


1 layout_width
Specifies the width of the View or ViewGroup
2 layout_height
Specifies the height of the View or ViewGroup
3 layout_marginTop
Specifies extra space on the top side of the View or ViewGroup
4 layout_marginBottom
Specifies extra space on the bottom side of the View or ViewGroup
5 layout_marginLeft
Specifies extra space on the left side of the View or ViewGroup
6 layout_marginRight
Specifies extra space on the right side of the View or ViewGroup
7 layout_gravity
Specifies how child Views are positioned
8 layout_weight
Specifies how much of the extra space in the layout should be allocated to the View

Units of Measurement

When you are specifying the size of an element on an Android UI, you should remember the
following units of measurement.

Sr.No Unit & description


1 dp
Density-independent pixel. 1 dp is equivalent to one pixel on a 160 dpi screen.
2 sp
Scale-independent pixel. This is similar to dp and is recommended for specifying font
sizes
3 pt
Point. A point is defined to be 1/72 of an inch, based on the physical screen size.
4 px
Pixel. Corresponds to actual pixels on the screen
Screen Densities

Sr.No Density & DPI


1 Low density (ldpi)
120 dpi
2 Medium density (mdpi)
160 dpi
3 High density (hdpi)
240 dpi
4 Extra High density (xhdpi)
320 dpi
Different XML Files Used in Android:
In Android there are several xml files used for several different purposes. Below we define each and
every one.
1. Layout XML Files: Layout xml files are used to define the actual UI(User interface) of our application.
It holds all the elements(views) or the tools that we want to use in our application. Like
the TextView’s, Button’s and other UI elements.
Location in Android Studio:
You will find out this file inside the res folder and inside it there is another folder named layout where
you will get all the layout files for their respective activities or fragments.

Basic Layout XML Code:


Below we show activity_main.xml file in which we have two TextView’s.

<!-- RelativeLayout in which we set green color for the background -->
<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="@color/greenColor"
tools:context=".MainActivity">

<TextView
android:id="@+id/firstTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:padding="10dp"
android:text="First Text View"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />
<!-- second TextView -->
<TextView
android:id="@+id/secondTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/firstTextView"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:padding="10dp"
android:text="Second Text View"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold" />

</RelativeLayout>

2. Manifest xml File(Mainfest.xml): This xml is used to define all the components of our application. It
includes the names of our application packages, our Activities, receivers, services and the permissions
that our application needs. For Example – Suppose we need to use internet in our app then we need to
define Internet permission in this file.
Location in Android Studio:
It is located inside app > manifests folder

Defining Internet Permission in AndroidManifest.xml


Below we show the AndroidManifest.xml file and define the Internet Permission in that file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.abhiandroid.MyApplication"> <!-- application package name -->

<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />


<!-- define Internet Permission -->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">

<!-- add your Activities, Receivers, Services Names Here -->


<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>

3. Strings xml File(strings.xml): This xml file is used to replace the Hard-coded strings with a single
string. We define all the strings in this xml file and then access them in our app(Activity or in Layout
XML files) from this file. This file enhance the reusability of the code.
Location in Android Studio:
Below we show strings.xml file and define a string in the file.

<resources>
<string name="app_name">My Application</string>

<string name="hello_world">Hello world!</string>


<string name="action_settings">Settings</string>
<string name="login">User Login</string>
<!-- define your strings here -->
</resources>

4. Styles xml File(styles.xml): This xml is used to define different styles and looks for the UI(User
Interface) of application. We define our custom themes and styles in this file.
Location in Android Studio:
Below we show the style.xml file.

<resources>

<!-- Base application theme. -->


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

</resources>

5. Drawable xml Files: These are those xml files that are used to provide various graphics to the
elements or views of application. When we need to create a custom UI we use drawable xml files.
Suppose if we need to define a gradient color in the background of Button or any custom shape for a
view then we create a Drawable xml file and set it in the background of View.
Do Read: How To Create Drawable Resource XML File in Android Studio
Below we show custom_drawable.xml file and create a gradient background color using style attribute.

<?xml version="1.0" encoding="utf-8"?>


<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- define start, center and end color for gradient -->
<gradient
android:centerColor="#0f0"
android:endColor="#00f"
android:startColor="#f00" />
</shape>

6. Color xml File (colors.xml): This file is used to define the color codes that we used in our app. We
simply define the color’s in this file and used them in our app from this file.
Location in Android Studio
Below we show the colors.xml file in which we define green and white color.

<?xml version="1.0" encoding="utf-8"?>


<resources>
<!-- define your colors Here -->
<color name="greenColor">#0f0</color>
<color name="white">#fff</color>
</resources>

7. Dimension xml File(dimens.xml): This xml file is used to define the dimensions of the View’s.
Suppose we need a Button with 50dp(density pixel) height then we define the value 50dp in dimens.xml
file and then use it in our app from this file.
Location in Android Studio:

Below we show the dimens.xml file in which we define 50dp dimension for Button height.

<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen><dimen name="btnheight">50dp</dimen>
</resources>

You might also like