Android Day 1

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

What is software ?

What is database?
What is data structure?
What is OS?

Installation done?

STACKOVERFLOW

OOPS
PIA
ANDROID

What is Android

Before learning all topics of android, it is required to


know what is android.

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, synoptics, 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 Platform.
History of Android
https://en.wikipedia.org/wiki/
Android_version_history
Features of Android
After learning what is android, let's see the features of
android. The important features of android are given
below:
1) It is open-source.
2) Anyone can customise the Android Platform.
Example: latest mobile companies.
3) There are a lot of mobile applications that can be
chosen by the consumer.
4) It provides many interesting features like weather
details, opening screen 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.

Android Architecture

android architecture or Android software


stack is categorised into five parts:
1. linux kernel
2. native libraries (middleware),
3. Android Runtime
4. Application Framework
5. Applications
Let's see the android architecture first.

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.

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 optimised 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.
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 kernel.
JVM (Java Virtual Machine)
Architecture
JVM (Java Virtual Machine) is an abstract
machine. It is a specification that provides
runtime environment in which java bytecode can
be executed.
JVMs are available for many hardware and
software platforms (i.e. JVM is platform
dependent).

The JVM performs following operation:


◦ Loads code
◦ Verifies code
◦ Executes code
◦ Provides runtime environment
JVM provides definitions for the:
◦ Memory area
◦ Class file format
◦ Register set
◦ Garbage-collected heap
◦ Fatal error reporting etc.
Dalvik Virtual Machine | DVM
As we know the modern JVM is high performance
and provides excellent memory management.
But it needs to be optimised for low-powered
handheld devices as well.
The Dalvik Virtual Machine (DVM) is an
android virtual machine optimised for mobile
devices. It optimises the virtual machine
for memory, battery life and performance.
Dalvik is a name of a town in Iceland. The Dalvik
VM was written by Dan Bernstein.
Installation of android studio?

What is IDE?
Benefits

Set your device your debugger.


Start Developer option ( Scroll to the bottom and tap Build
number 7 times.)
Open Developer options, and then scroll down to find and
enable USB debugging.

For windows user they need USB Drivers https://


developer.android.com/studio/run/oem-usb
NOW START THE GAME:

Discuss android project structure .


All folders
Menifest file
AndroidManifest.xml file in android
The AndroidManifest.xml file contains
information of your package, including
components of the application such as activities,
services, broadcast receivers, content providers
etc.
It performs some other tasks also:
◦ It is responsible to protect the
application to access any protected parts by
providing the permissions.
◦ It also declares the android api that the
application is going to use.
This is the required xml file for all the android
application and located inside the root directory.
Android R.java file
Android R.java is an auto-generated file by
aapt (Android Asset Packaging Tool) that
contains resource IDs for all the resources of res/
directory.
If you create any component in the
activity_main.xml file, id for the corresponding
component is automatically created in this file.
This id can be used in the activity source file to
perform any action on the component.

What happen if you delete it?

RUN HELLO WORLD PROGRAM??


Components of Android development

1. Activity
2. Services
3. Broadcast Receiver
4. Content Provider

INTENTS and BUNDLE

Examples?????
1. Activity
What is activity?
So called definition
An activity is a class that represents a single
screen. An activity is a single, focused thing that the
user can do. Almost all activities interact with the user,
so the Activity class takes care of creating a window for
you in which you can place your UI .

Its JAVA code?? Do you know java code


basics???
Inheritance and Interfaces ????
Overriding a method?
LIFECYCLE of ACTIVITY

Activity Lifecycle
Activities in the system are managed as an activity stack. When
a new activity is started, it is placed on the top of the stack and
becomes the running activity -- the previous activity always
remains below it in the stack, and will not come to the
foreground again until the new activity exits.

An activity has essentially four states:

1. Running
• If an activity is in the foreground of the screen (at the top
of the stack), it is active or running.

2. Paused
If an activity has lost focus but is still visible (that is, a new non-
full-sized or transparent activity has focus on top of your
activity), it is paused. 

A paused activity is completely alive

3. Stopped

• If an activity is completely obscured by another activity, it


is stopped. It still retains all state and member information,
however, it is no longer visible to the user so its window is
hidden and it will often be killed by the system when
memory is needed elsewhere.

4. Killed
• If an activity is paused or stopped, the system can drop
the activity from memory by either asking it to finish, or
simply killing its process. When it is displayed again to the
user, it must be completely restarted and restored to its
previous state.

How we will know all theses events


programmatically :
The entire lifecycle of an activity is defined by the following
Activity methods. All of these are hooks that you can override
to do appropriate work when the activity changes state.

Write down the program?

The onCreate() and onDestroy() methods are called only once


throughout the activity lifecycle.
Intent (VERY VERY IMPORTANT)

Communication between different


components

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.
…… and so on,,,,

IMPLICIT INTENT AND EXPLICIT


INTENT
Show example of explicit intent ???
startActivity(intent)

Pass data between activities


ACTIVITY STACK???

Give them assignment


Read about bundle and layouts.

EOD

You might also like