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

Android Basic Terms

The document provides information on various Android application components and concepts: - It discusses fragments, activities, services, content providers, and application widgets. - It also covers user interface elements like buttons, checkboxes, and navigation components. Concepts like intents, intent filters, and broadcast receivers are explained. - The lifecycle and methods to override in fragments are defined. How to use fragments by creating classes, layouts, and activity logic is outlined.

Uploaded by

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

Android Basic Terms

The document provides information on various Android application components and concepts: - It discusses fragments, activities, services, content providers, and application widgets. - It also covers user interface elements like buttons, checkboxes, and navigation components. Concepts like intents, intent filters, and broadcast receivers are explained. - The lifecycle and methods to override in fragments are defined. How to use fragments by creating classes, layouts, and activity logic is outlined.

Uploaded by

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

Unit 2 Topics

• User Interface and Application Components


• Fragments
• Widget
• Creating New View
• Introduction to Intents
• Intent Filters and broadcast Receivers
• Activities
• Services
• Content Providers
• Application Widgets
• Processes and Threads
USER INTERFACE ELEMENTS

User interface elements usually fall into one of the following four
categories:
• Input Controls
• Navigation Components
• Informational Components
• Containers
INPUT CONTROLS
Element Description
Checkboxes Checkboxes allow the user to select one or more options
from a set. It is usually best to present checkboxes in a
vertical list. More than one column is acceptable as well if
the list is long enough that it might require scrolling or if
comparison of terms might be necessary.
Radio Radio buttons are used to allow users to select one item
at a time.
buttons
Dropdown Dropdown lists allow users to select one item at a time,
similarly to radio buttons, but are more compact allowing
lists you to save space. Consider adding text to the field, such
as ‘Select one’ to help the user recognize the necessary
action.
List boxes List boxes, like checkboxes, allow users to select a multiple
items at a time,but are more compact and can support a
longer list of options if needed.
Buttons A button indicates an action upon touch and is typically
labeled using text, an icon, or both.
Element Description
Dropdown lists Dropdown lists allow users to select one item at
a time, similarly to radio buttons, but are more
compact allowing you to save space. Consider
adding text to the field, such as ‘Select one’ to
help the user recognize the necessary action.
List boxes List boxes, like checkboxes, allow users to select
a multiple items at a time, but are more
compact and can support a longer list of options
if needed.
Buttons A button indicates an action upon touch and is
typically labeled using text, an icon, or both.
Dropdown The dropdown button consists of a button that
when clicked displays a drop-down list of
Button mutually exclusive items.
Navigational Components
Element Description
Search Field A search box allows users to enter a
keyword or phrase (query) and submit
it to search the index with the
intention of getting back the most
relevant results. Typically search fields
are single-line text boxes and are often
accompanied by a search button.
Breadcrumb Breadcrumbs allow users to identify
their current location within the
system by providing a clickable trail of
proceeding pages to navigate by.
Pagination Pagination divides content up between
pages, and allows users to skip
between pages or go in order through
the content.
Element Description
Sliders A slider, also known as a track bar, allows users to set or
adjust a value.  When the user changes the value, it does
not change the format of the interface or other info on
the screen.
Icons An icon is a simplified image serving as an intuitive
symbol that is used to help users to navigate the system. 
Typically, icons are hyperlinked.
Information Components
Element Description
Notifications A notification is an update message that announces
something new for the user to see. Notifications are
typically used to indicate items such as, the successful
completion of a task, or an error or warning message.
Progress Bars A progress bar indicates where a user is as they
advance through a series of steps in a process.
Typically, progress bars are not clickable.
Tool Tips A tooltip allows a user to see hints when they hover
over an item indicating the name or purpose of the
item.
Containers
Element Description
Accordion An accordion is a vertically stacked list of items that utilizes show/ hide functionality. 
When a label is clicked, it expands the section showing the content within. There can have
one or more items showing at a time and may have default states that reveal one or more
sections without the user clicking
FRAGMENTS
• Android Fragment is the part of activity, it is also known as sub-activity. There can be more than
one fragment in an activity. Fragments represent multiple screen inside one activity.
• Android fragment lifecycle is affected by activity lifecycle because fragments are included in
activity.

• A fragment has its own layout and its own behaviour with its own life cycle callbacks.
• You can add or remove fragments in an activity while the activity is running.
• You can combine multiple fragments in a single activity to build a multi-pane UI.
• A fragment can be used in multiple activities.
• Fragment life cycle is closely related to the life cycle of its host activity which means when the
activity is paused, all the fragments available in the activity will also be stopped.
• A fragment can implement a behaviour that has no user interface component.
METHODS TO OVERRIDE IN YOUR FRAGMENT CLASS
• onAttach() it is called only once when it is attached with activity.
• onCreate() It is used to initialize the fragment.
• onCreateView() creates and returns view hierarchy.
• onActivityCreated() It is invoked after the completion of onCreate() method.
• onStart() - makes the fragment visible..
• onResume() - makes the fragment interactive..
• onPause() - Is called when fragment is no longer interactive.
• onStop() - Fragment going to be stopped by calling onStop()
• onDestroyView() - Fragment view will destroy after call this method
• onDestroy() - onDestroy() called to do final clean up of the fragment's state but Not guaranteed to be
called by the Android platform.
• onDetach() - It is called immediately prior to the fragment no longer being associated with its activity
HOW TO USE FRAGMENTS?
• This involves number of simple steps to create Fragments.
• First of all decide how many fragments you want to use in an activity. For
example let's we want to use two fragments to handle landscape and portrait
modes of the device.
• Next based on number of fragments, create classes which will extend
the Fragmentclass. The Fragment class has above mentioned callback
functions. You can override any of the functions based on your requirements.
• Corresponding to each fragment, you will need to create layout files in XML
file. These files will have layout for the defined fragments.
• Finally modify activity file to define the actual logic of replacing fragments
based on your requirement.
INTENT
• An Intent is a simple message object that is used to communicate
between android components such as activities, content providers,
broadcast receivers and services.
• Intents are also used to transfer data between activities.
• Use of Intent
• For Launching an Activity
• To start a New Service
• For Broadcasting Messages
• To Display a list of contacts in ListView
Types of Intent in Android
Intent is of two types:
• Implicit Intent
• Explicit Intent
• Implicit Intent
• The implicit intent is the intent where instead of defining the exact components,
you define the action that you want to perform for different activities.
• An Implicit intent specifies an action that can invoke any app on the device to be
able to perform an action. Using an Implicit Intent is useful when your app cannot
perform the action but other apps probably can and you’d like the user to pick
which app to use.
• Explicit Intent
• An explicit intent is an Intent where you explicitly define the
component that needs to be called by the Android System. An explicit
intent is one that you can use to launch a specific app component, such
as a particular activity or service in your app.
The Different Methods Used in Intent
• Action_Main
• Action_Pick
• Action_Chooser
• Action_Dial
• Action_Call
• Action_Send
• Action_SendTo
Content Provider
• A content provider manages access to a central repository of data.
• A provider is part of an Android application, which often provides its own UI for
working with the data.
• Content providers are primarily intended to be used by other applications
• Which access the provider using a provider client object. Together, providers and
provider clients offer a consistent, standard interface to data that also handles
inter-process communication and secure data access.
A content provider coordinates access to the data storage layer in your application
for a number of different APIs and components, these include:

•Sharing access to your application data with other applications


•Sending data to a widget
•Returning custom search suggestions for your application through the search
framework.
•Synchronizing application data with your server.
•Loading data in your UI.
WIDGET
• A widget is a small gadget or control of your android application placed on the
home screen.
• Widgets can be very handy as they allow you to put your favourite applications on
your home screen in order to quickly access them.
• You have probably seen some common widgets, such as music widget, weather
widget, clock widget e.t.c
• Widgets could be of many types such as information widgets, collection widgets,
control widgets and hybrid widgets. Android provides us a complete framework to
develop our own widgets
UNIT-4
User Experience Enhancement:
• Action Bar
• Menus and Action Bar Items
• Settings
• Dialogs
• Customizing Toast
• Notifications
• Search
• Drag and Drop
ACTION BAR
• The action bar is an important design element, usually at the top of each screen in an app, that
provides a consistent familiar look between Android apps.
• It is used to provide better user interaction and experience by supporting easy navigation through
tabs and drop-down lists.
• It also provides a space for the app or activity’s identity, thus enabling the user to know their
location in the app, and easy access to the actions that can be performed.
• The action bar consists of:
• App icon – This is used to identify your app with a logo or icon.
• View control – This can also be used to identify the app or the specific activity the user is
on by the title. If your app has different views, it can also be used to display these and
allow for easy switching between views.
• Action buttons – These are used to display the most important and/or often used actions. If
there isn’t enough space to show all of the action buttons, those that don’t fit are
automatically moved to the action overflow.
• Action overflow – This is used for the lesser used actions.
SETTINGS
• Settings allow users to change the functionality and behavior of an application.
• Settings can affect background behavior, such as how often the application synchronizes
data with the cloud, or they can be more wide-reaching, such as changing the contents and
presentation of the user interface.
• The recommended way to integrate user configurable settings into your application is to
use the AndroidX Preference Library.
• This library manages the user interface and interacts with storage so that you define only
the individual settings that the user can configure.
• The library comes with a Material theme that provides a consistent user experience across
devices and OS versions.
Dialogs
• A dialog is a small window that prompts the user to make a decision or enter additional
information. A dialog does not fill the screen and is normally used for modal events that require
users to take an action before they can proceed.
CUSTOMIZING TOAST
• In android, Toast is a small popup notification which is used to display an information
about the operation which we performed in our app.
• The Toast will show the message for a small period of time and it will disappear
automatically after a timeout.
• The size of Toast will be adjusted based on the space required for the message and it will
be displayed on the top of main content of an activity for a short period of time.
• The Toast notification in android will be displayed with simple text like as shown in above
image.
• In android, we can customize the layout of our toast notification to change the appearance
of based on requirements like include images in toast notification or change the
background colour of toast notification, etc.
 DRAG AND DROP
• The Drag and Drop framework will include following functionalities to support the data movement in android
applications.
Drag Event Class
Drag Listeners
Helper Methods and Classes

• The Drag and Drop process starts when user making gestures recognized as a signal to start dragging data and
application tells the system that the drag is starting.

• In android, the Drag and Drop process contains a 4 steps or states, those are
 Started
Continuing
Dropped
Ended
DATA AND FILE STORAGE OVERVIEW
• Android provides several options for you to save your app data.
• The solution you choose depends on your specific needs, such as how much space your data
requires, what kind of data you need to store, and whether the data should be private to your
app or accessible to other apps and the user.

• The different data storage options available on Android:

• Internal file storage: Store app-private files on the device file system.
• External file storage: Store files on the shared external file system. This is usually for shared
user files, such as photos.
• Shared preferences: Store private primitive data in key-value pairs.
• Databases: Store structured data in a private database.
INTERNAL FILE STORAGE
• By default, files saved to the internal storage are private to your app.
• This makes internal storage a good place for internal app data that the user doesn't need
to directly access.
• The system provides a private directory on the file system for each app where you can
organize any files your app needs.
• When the user uninstalls app, the files saved on the internal storage are removed.
• Because of this behavior, you should not use internal storage to save anything the user
expects to persist independently of your app.
• For example, if your app allows users to capture photos, the user would expect that
they can access those photos even after they uninstall your app.
• So you should instead use the mediastore API to save those types of files to the
appropriate media collection6
External storage
• Every Android device supports a shared "external storage" space that you can use to save files.
This space is called external because it's not guaranteed to be accessible.
• It is a storage space that users can mount to a computer as an external storage device, and it
might even be physically removable (such as an SD card).
• Files saved to the external storage are world-readable and can be modified by the user when
they enable USB mass storage to transfer files on a computer.
• So before you attempt to access a file in external storage in your app, you should check for the
availability of the external storage directories as well as the files you are trying to access.
• Most often, you should use external storage for user data that should be accessible to other
apps and saved even if the user uninstalls your app, such as captured photos or downloaded
files.
• The system provides standard public directories for these kinds of files, so the user has one
location for all their photos, ringtones, music, and such.
SHARED PREFERENCES
• If you don't need to store a lot of data and it doesn't require structure, you should use
SharedPrefrences.
• The SharedPrefrences APIs allow you to read and write persistent key-value pairs of primitive
data types: booleans, floats, ints, longs, and strings.
• The key-value pairs are written to XML files that persist across user sessions, even if your app is
killed. You can manually specify a name for the file or use per-activity files to save your data.
• The API name "shared preferences" is a bit misleading because the API is not strictly for saving
"user preferences," such as what ringtone a user has chosen.
• You can use SharedPrefrences to save any kind of simple data, such as the user's high score.
• if you do want to save user preferences for your app, then you should read how to create a
settings UI, which uses the AndroidX Prefrence Libraryto build a settings screen and automatically
persist the user's settings.
Databases

• Android provides full support for SQLite databases.


• However, instead of using SQLite APIs directly, we recommend that you create and
interact with your databases with the Room persistence library.
• The Room library provides an object-mapping abstraction layer that allows fluent
database access while harnessing the full power of SQLite.
• The SQLite APIs are fairly low-level and require a great deal of time and effort to use.
For example:
There is no compile-time verification of raw SQL queries.
As your schema changes, you need to update the affected SQL queries manually. This
process can be time consuming and error prone.
You need to write lots of boilerplate code to convert between SQL queries and Java
data objects.
File System
• Most of the Android user are using their Android phone just for calls,
SMS, browsing and basic apps, But form the development
prospective, we should know about Android internal structure.
• Android uses several partitions (like boot, system, recovery , data etc)
to organize files and folders on the device just like Windows OS.
• Each of these partitions has it’s own functionality, But most of us
don’t know the significance of each partition and its contents.
• There are mainly 6 partitions in Android phones, tablets and other
Android devices.
• /boot
• /system
• /recovery
• /data
• /cache
• /misc
Also Below are the for SD Card Fie System Partitions.
• /sdcard
• /sd-ext
/boot
• This is the boot partition of your Android device, as the name
suggests.
• It includes the android kernel and the ram disk.
• The device will not boot without this partition.
• Wiping this partition from recovery should only be done if absolutely
required and once done, the device must NOT be rebooted before
installing a new one, which can be done by installing a ROM that
includes a /boot partition.
/system
• As the name suggests, this partition contains the entire Android OS.
• This includes the Android GUI and all the system applications that
come pre-installed on the device.
• Wiping this partition will remove Android from the device without
rendering it unbootable, and you will still be able to put the phone into
recovery or bootloader mode to install a new ROM.
/recovery
• This is specially designed for backup.
• The recovery partition can be considered as an alternative boot
partition, that lets the device boot into a recovery console for
performing advanced recovery and maintenance operations on it.
/data
• It is called userdata partition.
• This partition contains the user’s data like your contacts, sms, settings
and all android applications that you have installed.
• While you are doing factory reset on your device, this partition will
wipe out, Then your device will be in the state, when you use for the
first time, or the way it was after the last official or custom ROM
installation.
/cache
• This is the partition where Android stores frequently accessed data and
app components.
• Wiping the cache doesn’t effect your personal data but simply gets rid
of the existing data there, which gets automatically rebuilt as you
continue using the device.
/misc
• This partition contains miscellaneous system settings in form of on/off
switches.
• These settings may include CID (Carrier or Region ID), USB
configuration and certain hardware settings etc.
• This is an important partition and if it is corrupt or missing, several of
the device’s features will not function normally.
/sdcard
• This is not a partition on the internal memory of the device but rather
the SD card.
• This is your storage space to use as you see fit, to store your media,
documents, ROMs etc. on it.
• Wiping it is perfectly safe as long as you backup all the data you
require from it, to your computer first.
• Though several user-installed apps save their data and settings on the
SD card and wiping this partition will make you lose all that data.
/sd-ext
• This is not a standard Android partition, but has become popular in the
custom ROM scene.
• It is basically an additional partition on your SD card that acts as the
/data partition.
• It is especially useful on devices with little internal memory allotted to
the /data partition.
• Thus, users who want to install more programs than the internal
memory allows can make this partition and use it for installing their
apps.

You might also like