Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

ANDROID

APPLICATION
DEVELOPMENT
-PALLABI SAHA
INTRODUCTION TO MOBILE APPS
Need of Mobile Apps

Number of mobile user is


more than desktop user

Apps provide better


personalization

Making use of device


features

Ease of work in offline and


online mode

Apps work faster than


websites
Different Type Of Mobile Apps

Native apps Hybrid


apps
Mobile Application Development

► A process by which an application software is developed for low level


handheld devices, such as PDA, EDA or mobile phones.
Other Platforms
INTRODUCTION TO ANDROID
Why Android?
What is Android?

► Android is an open source and Linux-based Operating


System for mobile devices
► Developed by the Open Handset Alliance (OHA), led by
Google, and other companies
► Developers are
► Andy Rubin
► Rich Miner
► Nick Sears
► Chris White
History

► Software platform from Google and OHA


► Originally owned by Android, Inc.
► July 2005, acquired by Google
► November 2007, OHA formed
► October 2008, available as open source
► December 2008, 14 new members joined
As an application

Easily
available in
Usually
Google Play
developed in
Store,
Java with the
Amazon App
Android SDK
Store and
support
different
other store
Features
Beautiful UI

Resizable
Connectivity
widgets

Multi
language Storage
support

Media
Multi tasking
Support

Web
Messaging
browser
Android API versions
Name Version number(s) Initial release date API level
1.0 September 23, 2008 1
No codename
1.1 February 9, 2009 2
Cupcake 1.5 April 27, 2009 3
Donut 1.6 September 15, 2009 4
Eclair 2.0 – 2.1 October 26, 2009 5–7
Froyo 2.2 – 2.2.3 May 20, 2010 8
Gingerbread 2.3 – 2.3.7 December 6, 2010 9 – 10
Honeycomb 3.0 – 3.2.6 February 22, 2011 11 – 13
Ice Cream Sandwich 4.0 – 4.0.4 October 18, 2011 14 – 15
Jelly Bean 4.1 – 4.3.1 July 9, 2012 16 – 18
KitKat 4.4 – 4.4.4 October 31, 2013 19 – 20
Lollipop 5.0 – 5.1.1 November 12, 2014 21 – 22
Marshmallow 6.0 – 6.0.1 October 5, 2015 23
Nougat 7.0 – 7.1.2 August 22, 2016 24 – 25
Oreo 8.0 – 8.1 August 21, 2017 26 – 27
Pie 9 August 6, 2018 28
Q (Android 10) 10 September 3, 2019 29
R (Android 11) 11 September 8, 2020 30
Android 12 12 October 4, 2021 31
ANDROID ARCHITECTURE
INSTALLATION OF ANDROID
Development Requirements

JDK 8 or above

Android SDK

Android Studio
Step -1 Setup java
► Install and set variable path
► To set the path, follow the process
► Right click on the My computer/ PC icon, select Advance system setting
Step 2-

Download and install ANDROID STUDIO from

https://developer.android.com/studio/
CREATING FIRST ANDROID APP
Start a new Project
(cont.)

► Thus after completion of all the steps, project environment setup starts and finally it
launches
► A java file and a xml file opens
► Xml file for designing purpose
► Java file for describing the data i.e. coding purpose
File Structure
Configuration
file
Package for Java
file

Folder for images

Layout file

File containing
color
File containing Strings

File for defining styles and


theme
AVD - Android Virtual Device or
Emulator

•Device similar to real android device

•Device which allow to test and run an app


ANDROID COMPONENTS
Main Components

•Activity
•Entry point for user interaction
•Represents single screen with a UI

•Service
•Entry point for keeping the app running in the background

•Broadcast Receiver
•Enables inflow and outflow of events

•Content Provider
•Manages a share set of data that can be stored in any storage (database, file
system, web, etc.)
•Helps in retrieving and modifying the data
Other Components

•Layouts
•Fragments
•Intent
•Views
•…
Layouts

•Constraint Layouts
•Layout within which each views are connected with either each other or with
the parent view (viewgroup)

•Relative Layouts
•Layout within which the views are arranged with respect to their relative
position

•Linear Layouts
•Layouts in which the view are arranged linearly, i.e. either horizontally(by
default) or vertically
BUILDING UI WITH ACTIVITIES
Activity Life Cycle
NOTIFICATIONS
Toast

► Provide a simple feedback about an operation in form of small popup


► Normally, a toast contains strings to display but we can make our toast
customised
► For customised toast, we need to create an additional layout xml file
► General syntax :
Toast.makeText( this, ” strings to display”,Toast.LENGTH_SHORT).show;

Here, makeText() help to create the content to the toast


show() help to make the Toast visible
Dialogs

► A small window that prompts the user to make a decision or enter additional
information
► A dialog can be a general dialog, an AlertDialog also
► For AlertDialog the syntax,
AlertDialog.Builder alert = new AlertDialog.Builder(this);
► Thus to include an alert dialog in an activity, we have to pass “this” as context
Status Bar Notifications

► A message that Android displays outside any app's UI to provide the user with
reminders, communication from other people, or other timely information
from your app
STYLES AND THEME
Color

► To change the existing color, change the color code in the color.xml file
► For example,
<color name=“colorPrimary”>#AD1457</color>
<color name=“colorPrimaryDark”>#78002e</color>
► To add new color to the app, color.xml file needs to be modified using the
<color> element
► For example,
<color name=“textColor”>#FFFFFF</color>
Theme

► To modify the existing theme of the app, change the theme of the app by
changing the <theme> in style.xml file
► To add new theme to the app, add new <theme> element in style.xml file
► Accordingly update the manifest file to apply the theme in specific activity
RESOURCES AND ASSET
Drawable Resources

► To add picture under drawable


► Android Studio in-built images
Right click on drawable -> New ->Vector Asset -> Double-Click on ClipArt-> Gallery opened ->
Select Image -> Finish

► User-choice image
► Copy the image and paste into the drawable folder
Accessing drawable image in ImageView

► XML ► JAVA

<ImageView ImageView iView;


android:id="@+id/iv" iView.setImageResource(R.drawable.img1);
android:layout_width="300dp"
android:layout_height="400dp"
android:src="@drawable/image1.jpg"/>
INTENT & INTENT FILTERS
Intent

► A messaging object that can be used to request an action from another app
component.
► For starting an activity
► Intent object is passed to startActivity()
► For starting a service
► Intent object is passed to startService()

► Intent is of 2 types
► Implicit
► Explicit
Intent-filter

► An element in manifest file


► It specifies the type of intent the activity accepts based on intent’s action, data and
category

► For example,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Here, it stated that the particular activity will act as main or starting point of the app
and it will be only be launched as soon as app icon is clicked
DATA STORAGE
SQLiteDatabase

► An in-built database of Android


► It has methods to create, delete, execute SQL commands, and perform other
common database management tasks
► To include SQLiteDatabase, we need to inherit SQLiteOpenHelper Class
► To execute the SQL query, we need to call a method
Database_object_name.execSQL(“SQL query”);

► To add data into the table, we need to get writable accesss


► The syntax to get the access,
this.getWritableDatabase();
cont.
► ContentValues
Class that used to store a set of values
► Thus it is used to insert data into the table in SQLiteDatabase
► Cursor
Interface that provides randrom read-write access to the result set returned by a
database query
Firebase

► A mobile platform that helps quickly develop high-quality apps


► To include Firebase in our project, follow the mentioned steps:
► Click on Tools -> Firebase
► Thus Assistant window(as shown in picture) will help with firebase
features
► For example,
► Expand the Authentication features
► Click on Connect to Firebase, it will automatically redirect to
firebase Console
► Thus, create a project with firebase and then continue adding
dependencies
► Follow the assistant window help
SERVICE
Services Overview

► An app component that can perform long-running operations in the


background
► It doesn’t provide any UI
► Different types of services:
► Foreground
► Background
► Bound
► To get the service component into the app, we need to add it to manifest file
using <service> element
MULTIMEDIA IN ANDROID
Adding a raw file
Click to create
raw directory
► Paste the raw data i.e. music file to add music to
the project
CAMERA AND GOOGLEMAP
Camera

► To get access of the camera,


► An intent object must be included as follows
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

► Now this intent can be used to set the captured image in an ImageView as
follows:
ImageView iView;
Bitmap pic = (Bitmap) data.getExtras().get(“data”);
iView.setImageBitmap(pic);
GoogleMap
(cont.)

► On adding the activity, 3 files get generated


► Layout xml file
► Contains the design for the map

► Google Api xml file within values


► In the file, we need to add the API key for running the map

► Java File
► Contains the java code for the map

You might also like