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

Android Notes Unit-1

Android is an open-source operating system used in many mobile devices. It offers features like a beautiful user interface, connectivity options, storage, media support, messaging, web browsing, multi-touch, multi-tasking, resizable widgets, multi-language support, cloud messaging, WiFi direct, and Android beam. Popular categories of Android applications include entertainment, tools, communication, productivity, personalization, music, social media, video, and travel. The document also discusses advantages like customization, cloud storage, continual improvements, third-party widgets, and running multiple apps. Disadvantages include slow performance on low-end devices, lack of default virus protection, ads in apps, difficulty executing new ideas, and mandatory

Uploaded by

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

Android Notes Unit-1

Android is an open-source operating system used in many mobile devices. It offers features like a beautiful user interface, connectivity options, storage, media support, messaging, web browsing, multi-touch, multi-tasking, resizable widgets, multi-language support, cloud messaging, WiFi direct, and Android beam. Popular categories of Android applications include entertainment, tools, communication, productivity, personalization, music, social media, video, and travel. The document also discusses advantages like customization, cloud storage, continual improvements, third-party widgets, and running multiple apps. Disadvantages include slow performance on low-end devices, lack of default virus protection, ads in apps, difficulty executing new ideas, and mandatory

Uploaded by

Aman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Unit-1

1. Explain Android and its features ?


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.

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 them are listed below −

Sr.No Feature & Description

Beautiful UI :
1
Android OS basic screen provides a beautiful and intuitive user interface.

Connectivity :
2
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and
WiMAX.

Storage :
3
SQLite, a lightweight relational database, is used for data storage purposes.

Media support :
4
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.

Messaging :
5
SMS and MMS

Web browser :
6
Based on the open-source WebKit layout engine, coupled with Chrome's V8
JavaScript engine supporting HTML5 and CSS3.

Multi-touch :
7
Android has native support for multi-touch which was initially made available in
handsets such as the HTC Hero.

Multi-tasking :
8
User can jump from one task to another and same time various application can run
simultaneously.

Resizable widgets :
9
Widgets are resizable, so users can expand them to show more content or shrink
them to save space.

Multi-Language :
10
Supports single direction and bi-directional text.
GCM :
11
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.
Wi-Fi Direct :
12
A technology that lets apps discover and pair directly, over a high-bandwidth peer-
to-peer connection.

Android Beam :
13
A popular NFC-based technology that lets users instantly share, just by touching
two NFC-enabled phones together.

Categories of Android applications


There are many android applications in the market. The top categories are −

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.

Apr08, 2021
Advantages and Disadvantages of
Google Android
Android Google as the name suggests, comes from the tech giant Google LLC. Android
Operating System is immensely popular across the globe and it’s evident from the fact that
Google Play Store offers more than 2 million apps to download and install in devices running
on it. A wide range of devices run on this OS including smartphones, tablets, watches, audio
players, TVs and PCs.

Like all good things, this popular OS has its advantages and disadvantages that we’ll explore
in this blog.

Advantages of Android :
• Android is an open-source platform allowing UI customization
Licensed under Apache, Android is an open source operating system whose codes developers
can change to build customized User Interface. App developers building applications for this
platform can get access to the core codes and are at a liberty to change the them to get the
customized outcomes. This is not possible when it comes to iOS and app have to strictly
adhere to the core code specifications when developing apps for the specific platform.

• Supports cloud storage enabling sync of devices with G-


account
Since Android is a Google product, users having Gmail account can have access to cloud
storage that are supported by the tech company. This means that users can sync devices using
Google accounts. Moreover, Google gives 15GB of free cloud storage to every user that is
good for an average person using it for personal purposes.

• Continual improvement & removal of old features


Google Android is supported by a huge community of developers and also users who
continue to give feedback about the features, their pros and cons. As a result, there is
continuous check on the codes and features, making modifications and alterations, bringing in
better upgrades all the time. This is one of the reasons why Android is always adding new
features while removing older ones that users do not like.

• Supports 3rd party widget & information display on screen


Android gives users the freedom to download 3rd party widgets and also display their content
on the home screen. If a user wishes to view time and temperature shown by a specific widget
on the home screen, it is possible with devices running on the platform.

• Supports running multiple apps simultaneously


With Android running on a device with good hardware specification, as a user you can have
multiple apps running simultaneously. You can continue to listen to music as you check your
messages or download files that you’ve received or even upload them from your device or
drive. There are a lot of Android app development companies who build applications based
on Android that are very useful in our daily lives.

• Expandable memory & runs on affordable large devices


One of the biggest advantages of using devices running on Android platform is that it
supports expandable memory. iOS devices on the other hand do not support external memory
expansion by adding memory card to the phone. Users of this platform enjoy the privilege of
storing e-books, music, videos and games on their devices.

• Wide range of devices to choose from


Android users are spoilt for choice of smartphone devices of different prices. There is
something for people across all budget spectrum when it comes to smartphones running on
Android. Almost all companies build devices that support Android platform giving users
multiple options when buying. This is something that is very restrictive for Apple users who
have to stick to the company’s expensive devices only!

Disadvantages of Android
• Runs slow on low-specification devices
Android operating system is huge and occupies a lot of space. This is the reason that phones
with low hardware specifications run slow on this OS. Moreover, it comes with several
default apps that further slow down the smartphone operation. This leaves no scope of
downloading external apps and also leads to heating issues of the device.

• Doesn’t offer premium virus protection


Android doesn’t come with default virus protection like Apple devices but, users need to
download anti-virus systems to protect the device from getting affected. A lot apps in Google
Play Store may contain viruses that will ultimately affect the device and its operations.

• Apps continue to run in the background


Devices running on older Android versions still have apps running in the background that can
also come to the foreground automatically. Newer version of Android of course does not let
the apps come to the foreground but if the apps continue to run, it naturally consumes battery
power.

• Users boomeranged with ads in apps


Apps that are downloaded from Play Store usually come with a lot of advertisements that
users have to put up with while using the application. To experience an ad-free users-
experience, you need to buy the license.

• Often totally new app ideas difficult to execute


Apps with totally new ideas have a difficult time entering the Android market as Play Store is
already flooded with millions of apps. Companies are often wary of entering the Android
market with latest ideas that will make a mark.

• Often apps are bad quality disappointing users


A lot of apps on Play Store come with poor quality and bad user-experience as their only
purpose is to earn money through ad display. You may also come across several apps that
have not been updated for years that end up affecting the updated operating system.

• Google account mandatory to use Play Store


Android is a Google product and you need a Google account to get access to Play Store and
also sync devices of other Google users.

All said and done, Android still continues to be extremely popular among smartphone users
worldwide as all types of devices support it. Apps for Android can be customized giving
users the effect that they want taking the platform’s popularity further ahead.

Installation Steps Android Studio


System Requirements

● Microsoft Windows 7/8/10 (32-bit or 64-bit)


● 4 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android
Emulator)
● 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus
1.5 GB for Android SDK and emulator system image)
● 1280 x 800 minimum screen resolution

Installation Guide

Step 1: Head over to this link to get the Android Studio executable or zip file.

Step 2: Click on the Download Android Studio Button.


Click on the “I have read and agree with the above terms and conditions” checkbox followed
by the download button.

Click on the Save file button in the appeared prompt box and the file will start downloading.

Step 3: After the downloading has finished, open the file from downloads and run it. It will
prompt the following dialog box.
Click on next. In the next prompt, it’ll ask for a path for installation. Choose a path and hit
next.

Step 4: It will start the installation, and once it is completed, it will be like the image shown
below.

Click on next.
Step 5: Once “Finish” is clicked, it will ask whether the previous settings need to be
imported [if the android studio had been installed earlier], or not. It is better to choose the
‘Don’t import Settings option’.

Click the OK button.

Step 6: This will start the Android Studio.


Meanwhile, it will be finding the available SDK components.

Step 7: After it has found the SDK components, it will redirect to the Welcome dialog box.
Click on Next.

Choose Standard and click on Next. Now choose the theme, whether the Light theme or the
Dark one. The light one is called the IntelliJ theme whereas the dark theme is called
Dracula. Choose as required.
Click on the Next button.

Step 8: Now it is time to download the SDK components.

Click on Finish. Components begin to download let it complete.


The Android Studio has been successfully configured. Now it’s time to launch and build
apps. Click on the Finish button to launch it.

Step 9: Click on Start a new Android Studio project to build a new app.
Hello Word Example

Before Writing a Hello word code, you must know about XML tags.To write hello word
code, you should redirect to App>res>layout>Activity_main.xml

To show hello word, we need to call text view with layout ( about text view and layout, you
must take references at Relative Layout and Text View ).
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="@string/hello_world"
android:layout_width="550dp"
android:layout_height="wrap_content" />
</RelativeLayout>
Need to run the program by clicking Run>Run App or else need to call shift+f10key.
Finally, result should be placed at Virtual devices as shown below

Create Android Application


The first step is to create a simple Android Application using Android studio. When you click
on Android studio icon, it will show screen as shown below
You can start your application development by calling start a new
android studio project. in a new installation frame should ask
Application name, package information and location of the project.

After entered application name, it going to be called select the
form factors your application runs on, here need to specify
Minimum SDK, in our tutorial, I have declared as API23: Android
6.0(Mashmallow) −

The next level of installation should contain selecting the activity to mobile, it specifies the
default layout for Applications.
At the final stage it going to be open development tool to write the application code.

Anatomy of Android Application


Before you run your app, you should be aware of a few directories
and files in the Android project −
Sr.No Folder, File & Description
.

Java

1 This contains the .java source files for your project. By default, it includes an
MainActivity.java source file having an activity class that runs when your app is
launched using the app icon.

res/drawable-hdpi
2
This is a directory for drawable objects that are designed for high-density screens.

res/layout
3
This is a directory for files that define your app's user interface.
res/values
4
This is a directory for other various XML files that contain a collection of
resources, such as strings and colours definitions.

AndroidManifest.xml
5
This is the manifest file which describes the fundamental characteristics of the app
and defines each of its components.

Build.gradle

6 This is an auto generated file which contains compileSdkVersion,


buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode
and versionName

Following section will give a brief overview of the important application files.

The Main Activity File


The main activity code is a Java file MainActivity.java. This is the actual application file
which ultimately gets converted to a Dalvik executable and runs your application. Following
is the default code generated by the application wizard for Hello World! application −

package com.example.helloworld;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Here, R.layout.activity_main refers to the activity_main.xml file located in the res/layout


folder. The onCreate() method is one of many methods that are figured when an activity is
loaded.

The Manifest File


Whatever component you develop as a part of your application, you must declare all its
components in a manifest.xml which resides at the root of the application
project directory. This file works as an interface between Android
OS and your application, so if you do not declare your component in
this file, then it will not be considered by the OS. For example, a
default manifest file will look like as following file −

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


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tutorialspoint7.myapplication">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Here <application>...</application> tags enclosed the components related to the application.


Attribute android:icon will point to the application icon available under res/drawable-hdpi.
The application uses the image named ic_launcher.png located in the drawable folders

The <activity> tag is used to specify an activity and android:name attribute specifies the fully
qualified class name of the Activity subclass and the android:label attributes specifies a string
to use as the label for the activity. You can specify multiple activities using <activity> tags.

The action for the intent filter is named android.intent.action.MAIN to indicate that this
activity serves as the entry point for the application. The category for the intent-filter is
named android.intent.category.LAUNCHER to indicate that the application can be launched
from the device's launcher icon.

The @string refers to the strings.xml file explained below. Hence, @string/app_name refers
to the app_name string defined in the strings.xml file, which is "HelloWorld". Similar way,
other strings get populated in the application.

Following is the list of tags which you will use in your manifest
file to specify different Android application components −

● <activity>elements for activities


● <service> elements for services
● <receiver> elements for broadcast receivers
● <provider> elements for content providers
The Strings File
The strings.xml file is located in the res/values folder and it contains all the
text that your application uses. For example, the names of buttons,
labels, default text, and similar types of strings go into this file.
This file is responsible for their textual content. For example, a
default strings file will look like as following file −

<resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>

The Layout File


The activity_main.xml is a layout file available in res/layout directory, that is
referenced by your application when building its interface. You
will modify this file very frequently to change the layout of your
application. For your "Hello World!" application, this file will have
following content related to default 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" >

<TextView
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=".MainActivity" />

</RelativeLayout>

This is an example of simple RelativeLayout which we will study in a separate chapter. The
TextView is an Android control used to build the GUI and it have various attributes like
android:layout_width, android:layout_height etc which are being used to set its width and
height etc.. The @string refers to the strings.xml file located in the res/values folder. Hence,
@string/hello_world refers to the hello string defined in the strings.xml file, which is "Hello
World!".
Running the Application
Let's try to run our Hello World! application we just created. I assume you had created your
AVD while doing environment set-up. To run the app from Android studio, open one of your
project's activity files and click Run icon from the tool bar. Android studio
installs the app on your AVD and starts it and if everything is fine
with your set-up and application, it will display following
Emulator window −

What is 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.Testing Android applications on emulator are sometimes faster and easier than doing on
a real device. For example, we can transfer data faster to the emulator than to a real device
connected through USB.
The Android emulator comes with predefined configurations for several Android phones,
Wear OS, tablet, Android TV devices.

Run an Android app on the Emulator


We can run an Android app form the Android Studio project, or we can run an app which is
installed on the Android Emulator as we run any app on a device.

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:

1. Open the AVD Manager.


2. Double-click an AVD, or click Run

While the emulator is running, we can run the Android Studio project and select the emulator
as the target device. We can also drag an APKs file to install on an emulator, and then run
them.

Start the emulator from the command line


The Android SDK includes the Android device emulator. Android emulator lets you develop
and test out the application without using a physical device.

Starting the emulator

Using the emulator command, we will start an emulator. It is an alternative to run our project
or start through the AVD Manager.

Here is the basic command-line syntax for starting a virtual device:

1. $ emulator -avd avd_name [ {-option [value]} ... ]

or

1. $ emulator @avd_name [ {-option [value]} ... ]

For example, if we execute the emulator from Android Studio on a Mac, the default
command line will be similar as follows:

1. $ /Users/user_name/Library/Android/sdk/emulator/emulator -avd Nexus_5X_API_23


-netdelay none -netspeed full

To display the list of AVD names, enter the following command:

1. $ emulator -list-avds

Run and stop an emulator, and clear data


From the Virtual Device page, we can perform the following operation on emulator:
● To run an Android emulator that uses an AVD, double-click the AVD, or click
Launch
● To stop the running emulator, right-click and select Stop, or click Menu ▼ and select
Stop.
● If we want to clear the data from an emulator and return it to the initial state when it
was first defined, then right-click an AVD and select Wipe Data. Or click menu ▼
and select Wipe Data.

Building Blocks of Android :

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.

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
● Broadcast a message
● Dial a phone call etc.

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.

AndroidManifest.xml

It contains informations 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.

You might also like