Android Training (android fundamental)

22
Android 1 Android Training By Khaled Anaqwa

description

Android Training (android fundamental)

Transcript of Android Training (android fundamental)

Page 1: Android Training (android fundamental)

Android 1Android Training

By Khaled Anaqwa

Page 2: Android Training (android fundamental)

WHAT MAKES AN ANDROID APPLICATION?

Activities Service Content Providers Intents Broadcast Receivers Widgets Notifications

Page 3: Android Training (android fundamental)

Activities An activity represent a single screen with a

user interface Most applications contain multiple activities When a new activity starts, it is pushed onto

back stack User interface can built with xml or java(xml

is recommended) Monitor lifespan through callback methods

like onStart() , onPause() ,etc

Page 4: Android Training (android fundamental)

Service Services perform long-running operations in

the background Dose not contain a user interface Useful for things like network operations,

playing music , etc. Run independently of the component that

created it. Can be bound to by other application

components, if allowed (when all of them unbind, the service is destroyed)

Page 5: Android Training (android fundamental)

Content Providers Used to store and retrieve data and make it

accessible to all applications(the only way to share data across apps)

They encapsulate the data, and provide mechanisms for defining data security

connects data in one process with code running in another process.

Exposes a public URI that uniquely identifies data set Data is exposed as a simple table on DB model Android contains many providers for things like

contacts, media ,etc

Page 6: Android Training (android fundamental)

Broadcast Receivers Is a component that responds to

system-wide broadcast announcements Example :announcing that the screen

has turned off , the battery is low, etc. App can also initiate their own

broadcasts Contain no user interface They can create status bar notifications

Page 7: Android Training (android fundamental)

APPLICATION’S PRIORITY AND ITS PROCESS’ STATES

All Android applications continue running and in memory until the system needs resources for other applications.

Page 8: Android Training (android fundamental)

1. Active processes Active (foreground) processes have

application components the user is interacting with.

Activities in an active state Broadcast Receivers executing onReceive Services executing onStart, onCreate Running Services that have been flagged

to run in the foreground

Page 9: Android Training (android fundamental)

2. Visible processes

Visible but inactive processes are those hosting “visible” Activities. This happens when an Activity is only partially obscured (by a non-full-screen or transparent Activity).

Page 10: Android Training (android fundamental)

3. Started Service processes

Processes hosting Services that have been started. Because these Services don’t interact directly with the user, they receive a slightly lower priority than visible Activities or foreground Services.

Page 11: Android Training (android fundamental)

4. Background processes

Processes hosting Activities that aren’t visible and that don’t have any running Services. There will generally be a large number of background processes that Android will kill using a last-seen-first-killed pattern in order to obtain resources for foreground processes.

Page 12: Android Training (android fundamental)

5. Empty processes

To improve overall system performance, Android will often retain an application in memory after it has reached the end of its lifetime. Android maintains this cache to improve the start-up time of applications when they’re relaunched.

These processes are routinely killed, as required.

Page 13: Android Training (android fundamental)
Page 14: Android Training (android fundamental)

Manifest XML It names the Java package for the application(unique

identifier for the app.) It describes the components of the application It determines which processes will host application

components. It declares which permissions the application must have permissions that others are required to have in order to

interact with the application's components. It declares the minimum level of the Android API that the

application requires. It lists the libraries that the application must be linked

against.

Page 15: Android Training (android fundamental)

How Android features are reflected in the manifest file? Intent Filters Icons and Labels Permissions Libraries

Page 16: Android Training (android fundamental)

Intent Filters The core components of an application

(its activities, services, and broadcast receivers) are activated by intents.

An intent is a bundle of information (an Intent object) describing a desired action including the data to be acted upon, the category of component that should perform the action, and other pertinent instructions.

Page 17: Android Training (android fundamental)

By Actions

Page 18: Android Training (android fundamental)

By Category

Page 19: Android Training (android fundamental)

Permission A permission is a restriction limiting access

to a part of the code or to data on the device. The limitation is imposed to protect critical data and code that could be misused to distort or damage the user experience.

here are some permissions defined by Android:

android.permission.CALL_EMERGENCY_NUMBERS android.permission.READ_OWNER_DATA android.permission.SET_WALLPAPER android.permission.DEVICE_POWER

Page 20: Android Training (android fundamental)

Type of Permissions <uses-permission> <permission> <permission-tree>(element declares a

namespace for a group of permissions) <permission-group>(defines a label for

a set of permissions) (tree-group)It affects only how the

permissions are grouped when presented to the user.

Page 21: Android Training (android fundamental)

Libraries

<uses-library android:name="string" android:required=["true" | "false"] />

Specifies a shared library that the application must be linked against. This element tells the system to include the library's code in the class loader for the package.

Google Play uses the <uses-library> elements declared in your app manifest to filter your app from devices that do not meet it's library requirements.

Page 22: Android Training (android fundamental)

All of the android packages such as android.app (application components) android.content(Content sharing,

Resource,Package management) android.view (basic user interface classes

that handle screen layout and interaction with the user.)

android.widget (mostly visual UI elements)

are in the default library that all applications are automatically linked against. some packages (such as maps) are in

separate libraries that are not automatically linked.