Android Fundamentals Concepts
Android Fundamentals Concepts
Concepts
1
Views
2
Types of Views
• Basic Views - commonly-used views such as TextView, EditText, and
Button views
• Picker Views - views that allows users to select from, such as the
TimePicker and DatePicker views
• List Views - views that display a long list of items, such as the ListView
and the Spinner views
• Display Views - views that display images, such as the Gallery and
ImageSwitcher views
• Menus - views that displays additional and context sensitive menu
items
• Additional Views - interesting views such as the AnalogClock and
DigitalClock views 3
Activity
4
Activity
5
Activity
• When an activity is stopped because a new activity starts, it is notified of this change in state
through the activity's lifecycle callback methods.
• There are several callback methods that an activity might receive, due to a change in its state—
whether the system is creating it, stopping it, resuming it, or destroying it—and each callback
provides you the opportunity to perform specific work that's appropriate to that state change
• . For instance, when stopped, your activity should release any large objects, such as network or
database connections.
• When the activity resumes, you can reacquire the necessary resources and resume actions that were
interrupted.
7
Intents
• There are two types of intents:
• Explicit intents specify the component to start by name (the fully-
qualified class name). You'll typically use an explicit intent to start a
component in your own app, because you know the class name of the
activity or service you want to start. For example, start a new activity in
response to a user action or start a service to download a file in the
background.
• Implicit intents do not name a specific component, but instead declare a
general action to perform, which allows a component from another app
to handle it. For example, if you want to show the user a location on a
map, you can use an implicit intent to request that another capable app
show a specified location on a map.
8
Content Providers
9
Androidmanifest.xml
• Every application must have an AndroidManifest.xml file (with precisely that
name) in its root directory
• The manifest file presents essential information about your app to the Android
system i.e. information the system must have before it can run any of the app's
code
• It names the Java package for the application. The package name serves as a
unique identifier for the application.
• It describes the components of the application — the activities, services,
broadcast receivers, and content providers that the application is composed
of.
• It names the classes that implement each of the components and publishes
their capabilities. These declarations let the Android system know what the
components are and under what conditions they can be launched.
• It determines which processes will host application components.
10
Androidmanifest.xml
11
Androidmanifest.xml
• the most important items in an AndroidManifest.xml file are the activity elements.
• A single Android app can have many activities, and each activity must have its own activity element
in the app’s AndroidManifest.xmlfile.
• If you add an activity’s Java code to an Android application, you must also add an activity element
to the application’s AndroidManifest.xmlfile.
• If you forget to add an activity element, you see anActivityNotFoundException when you try to run
the application.
• Within an activity element, an intent-filter element describes the kinds of duties that this activity
can fulfill for apps on the same device.
• To give you an idea, the action android.intent.action.MAIN indicates that this activity’s code can be
the starting point of an app’s execution. And the
category android.intent.category.LAUNCHER indicates that this activity’s icon can appear on the
device’s Apps screen.
12
Other Core Components
• Service
• A service doesn't have a visual user interface, runs in the
background for a period of time
• Broadcast receivers
• a component that does nothing but receive and react to broadcast
announcements
• Content providers
• A content provider makes a specific set of the application's data
available to other applications.
• The data can be stored in the file system, in an SQLite database, or
in any other manner that makes sense
13