A new Linux process is started for an application with a single thread of execution. By default, all application components run in the same process and thread. Additional processes and threads can be created. The Android system tries to keep processes running as long as possible by placing them in an importance hierarchy, with foreground processes being least likely to be killed. The cached process of an inactive application is most likely to be killed first when memory is low.
This document provides summaries of various Firebase products and services, including Firebase Realtime Database, Firebase Authentication, Firebase Cloud Messaging, Firebase Notifications, Firebase Storage, Firebase Hosting, Firebase Test Lab for Android, and Firebase Crash Reporting. For each product or service, the document outlines its key capabilities and provides example use cases.
Androids' memory management differ from the other operating systems. In this PowerPoint presentation we tried to figure out how it works and how it differs from other operating systems.
Android uses Views and ViewGroups to create user interfaces. Views occupy rectangular areas on screen and handle drawing and events. Common widgets like Buttons and TextViews are subclasses of View. Layouts like LinearLayout and RelativeLayout are ViewGroups that position child Views. Layout parameters specify how Views are positioned. Common event listeners include onClick and onTouch, which call registered event handlers when triggered by user interaction.
An operating system acts as an interface between the user and computer hardware, controlling program execution and performing basic tasks like file management, memory management, and input/output control. There are four main types of operating systems: monolithic, layered, microkernel, and networked/distributed. A monolithic OS has all components in the kernel, while layered and microkernel OSes separate components into different privilege levels or layers for modularity. Networked/distributed OSes enable accessing resources across multiple connected computers.
Introduction to Android development - PresentationAtul Panjwani
A powerpoint presentation on Introduction to android development
prepared for college seminar
[Report is also uploaded named "Introduction to Android development - Presentation Report"]
Source: developer.android.com
The document discusses how to create an executable JAR file in Java. It explains that a JAR file allows combining multiple classes into a single file and can be run directly if a manifest file specifies the main class. It provides steps to create a manifest file identifying the main class and use the JAR tool to package the compiled classes and manifest into a runnable JAR file that can then be executed. Instructions are given for creating JAR files in both JCreator and the command prompt.
- Shell scripting allows users to automate repetitive tasks by writing scripts of shell commands that can be executed automatically. The shell acts as an interface between the user and the operating system kernel, accepting commands and passing them to the kernel for execution. Common shells used for scripting include Bash, C Shell, and Korn Shell. Shell scripts use shell commands, control structures, and functions to perform automated tasks like backups and system monitoring.
This document provides summaries of various Firebase products and services, including Firebase Realtime Database, Firebase Authentication, Firebase Cloud Messaging, Firebase Notifications, Firebase Storage, Firebase Hosting, Firebase Test Lab for Android, and Firebase Crash Reporting. For each product or service, the document outlines its key capabilities and provides example use cases.
Androids' memory management differ from the other operating systems. In this PowerPoint presentation we tried to figure out how it works and how it differs from other operating systems.
Android uses Views and ViewGroups to create user interfaces. Views occupy rectangular areas on screen and handle drawing and events. Common widgets like Buttons and TextViews are subclasses of View. Layouts like LinearLayout and RelativeLayout are ViewGroups that position child Views. Layout parameters specify how Views are positioned. Common event listeners include onClick and onTouch, which call registered event handlers when triggered by user interaction.
An operating system acts as an interface between the user and computer hardware, controlling program execution and performing basic tasks like file management, memory management, and input/output control. There are four main types of operating systems: monolithic, layered, microkernel, and networked/distributed. A monolithic OS has all components in the kernel, while layered and microkernel OSes separate components into different privilege levels or layers for modularity. Networked/distributed OSes enable accessing resources across multiple connected computers.
Introduction to Android development - PresentationAtul Panjwani
A powerpoint presentation on Introduction to android development
prepared for college seminar
[Report is also uploaded named "Introduction to Android development - Presentation Report"]
Source: developer.android.com
The document discusses how to create an executable JAR file in Java. It explains that a JAR file allows combining multiple classes into a single file and can be run directly if a manifest file specifies the main class. It provides steps to create a manifest file identifying the main class and use the JAR tool to package the compiled classes and manifest into a runnable JAR file that can then be executed. Instructions are given for creating JAR files in both JCreator and the command prompt.
- Shell scripting allows users to automate repetitive tasks by writing scripts of shell commands that can be executed automatically. The shell acts as an interface between the user and the operating system kernel, accepting commands and passing them to the kernel for execution. Common shells used for scripting include Bash, C Shell, and Korn Shell. Shell scripts use shell commands, control structures, and functions to perform automated tasks like backups and system monitoring.
The document summarizes the different resource types used in an Android application. Resources like animations, colors, drawables, layouts, menus and strings are stored in the res folder and accessed via their respective R classes. The src folder contains Java source code, gen contains the R class, assets stores raw files, and bins has compiled code. Resources support different densities in drawable folders. Layouts define UIs and values contains simple data like strings.
CORBA and DCOM are specifications for distributed computing that allow objects to communicate across a network. CORBA uses an Object Request Broker (ORB) as middleware to locate and invoke remote objects transparently. It defines an Interface Definition Language (IDL) and supports location transparency. DCOM is Microsoft's version that extends COM to allow components to interact remotely. It uses proxies on the client side and stubs on the server side to marshal requests and responses.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
The document discusses the core components of an Android application including activities, services, broadcast receivers, and content providers. It describes how these components are declared in the manifest file and how they are activated via intents. The document also covers the application resources, project structure, and security model of Android applications.
This document describes the functions of various Linux commands, including commands for listing files (ls), creating directories (mkdir) and files (touch, cat), copying files (cp), changing directories (cd), moving files (mv), finding file locations (whereis, which), displaying manual pages (man, info), checking disk usage (df, du), viewing running processes (ps), setting aliases (alias), changing user identity (su, sudo), viewing command history (history), setting the system date and time (date), displaying calendars (cal), and clearing the terminal screen (clear). It provides the syntax and examples for using each command.
This document provides an introduction to multiprocessor systems. It describes how multiprocessor systems use multiple processors together to improve performance and speed over uniprocessor systems. Multiprocessor systems can be tightly or loosely coupled. Tightly coupled systems share memory and communication while loosely coupled systems use separate processors connected via a network. The document discusses different interconnection techniques for multiprocessors like bus-oriented, crossbar, and multistage switching systems. It also covers multiprocessor operating systems and their functions in supporting parallel processing across CPUs.
This document discusses an Android application for a Sudoku game and its relation to the Android operating system. It first defines Android as a software stack including an OS, middleware and apps. It then explains that an Android app is designed to run on Android devices like smartphones and tablets. It describes the Sudoku game app the presenter created for Android, including difficulty settings and options for sounds and hints. It outlines the four layers of the Android OS - the Linux kernel, libraries and runtime, application framework, and applications. It discusses how the Sudoku app uses specific libraries and components from the Android framework like SQLite for data storage, the 2D graphics library, and the activity manager.
Android is an open source software platform for mobile devices based on the Linux kernel. It includes APIs for app development, core applications like email and maps, and services like notifications and activity management. At its core are the Dalvik virtual machine, C/C++ libraries, and underlying Linux system functionality that allow Android to run efficiently on various hardware configurations and platforms.
The document discusses clients and servers, middleware, and different types of client-server architectures. It provides definitions and examples of clients, servers, middleware, fat clients, fat servers, 2-tier architectures, and 3-tier architectures. It also compares characteristics and advantages of 2-tier vs 3-tier architectures.
This document provides an introduction to object-oriented programming and Java. It discusses the basics of OOP concepts like classes, objects, encapsulation, inheritance, polymorphism and dynamic binding. It explains the benefits of OOP like modularity, code reuse and information hiding. The document also outlines some key features of the Java programming language like platform independence, security, simplicity and performance. It positions Java as a pure object-oriented language suitable for developing both standalone applications and web applets.
The document provides tutorials for various user interface widgets in Android application development. It includes tutorials for date pickers, time pickers, spinners, buttons, text fields, checkboxes, radio buttons, toggle buttons, and rating bars. Each tutorial section describes how to add the widget to an app layout, populate it with data where applicable, and add click listeners or other logic to handle user interactions with the widget. The tutorials are intended to demonstrate how to correctly implement and use common UI elements in Android apps.
This presentation is about the introduction, history and inner supporting managing system of Operating System.
how Process Scheduling and file management works by Windows.
Tk2323 lecture 1 introduction to mobile applicationMengChun Lam
The document provides an introduction to a mobile application development course. It outlines topics that will be covered including Android architecture, mobile development considerations like device fragmentation and limited resources, and different app development methods like native, hybrid and web apps. It also introduces key mobile platforms like Android and iOS and how apps are distributed for each.
A short explanation of Architecture of operating system. In this slide i explain about monolithic OS , layer OS, microkernel OS and networked and distributed OS with their architecture.
An Android application is composed of activities, services, and content providers. Activities display user interfaces and are launched by intents. The context provides access to application-wide resources and functionality. Activities have a lifecycle of states like resumed, paused, and stopped that are called back through methods to manage resources. Intents are used to transition between activities within an app or launch other apps' components.
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiSowmya Jyothi
Unix is a multitasking, multiuser operating system developed in 1969 at Bell Labs. It allows multiple users to use a computer simultaneously and users can run multiple programs at once. There are several Unix variants like Solaris, AIX, and Linux. Unix was originally written for the PDP-7 computer in C programming language, making it portable. It uses a hierarchical file system and treats all resources as files with permissions. Processes run programs and the shell interprets commands to run programs or interact with the kernel for system calls. Everything in Unix is either a file or a process.
This document discusses process management in Android. It describes how Android applications run in processes and the different application components like activities, services, broadcast receivers, and content providers. It covers the process lifecycle and importance hierarchy. It also discusses threads, inter-process communication, deadlock handling, and the CPU scheduling policy in Android, including completely fair scheduling, nice values, control groups, schedtune, and cpuset.
Threads handlers and async task, widgets - day8Utkarsh Mankad
This document discusses processes and threads in Android, process lifecycles, thread management principles, and how to create and manage widgets in Android. It covers the following key points:
- Processes and threads in Android and how the main thread handles UI events.
- The 5 levels of importance for application processes and when processes are killed.
- Using handlers and AsyncTasks to perform background work without blocking the UI thread.
- The basics of widgets including the AppWidgetProviderInfo, AppWidgetProvider class, and layout.
- The steps to create a widget including declaring it in the manifest, metadata, layouts, provider class, and configuration activity.
The document summarizes the different resource types used in an Android application. Resources like animations, colors, drawables, layouts, menus and strings are stored in the res folder and accessed via their respective R classes. The src folder contains Java source code, gen contains the R class, assets stores raw files, and bins has compiled code. Resources support different densities in drawable folders. Layouts define UIs and values contains simple data like strings.
CORBA and DCOM are specifications for distributed computing that allow objects to communicate across a network. CORBA uses an Object Request Broker (ORB) as middleware to locate and invoke remote objects transparently. It defines an Interface Definition Language (IDL) and supports location transparency. DCOM is Microsoft's version that extends COM to allow components to interact remotely. It uses proxies on the client side and stubs on the server side to marshal requests and responses.
This document provides an overview of Java servlets technology, including:
1. What Java servlets are and their main purposes and advantages such as portability, power, and integration with server APIs.
2. Key aspects of servlet architecture like the servlet lifecycle, the HttpServletRequest and HttpServletResponse objects, and how different HTTP methods map to servlet methods.
3. Examples of simple servlets that process parameters, maintain a session counter, and examples of deploying servlets in Eclipse IDE.
The document discusses the core components of an Android application including activities, services, broadcast receivers, and content providers. It describes how these components are declared in the manifest file and how they are activated via intents. The document also covers the application resources, project structure, and security model of Android applications.
This document describes the functions of various Linux commands, including commands for listing files (ls), creating directories (mkdir) and files (touch, cat), copying files (cp), changing directories (cd), moving files (mv), finding file locations (whereis, which), displaying manual pages (man, info), checking disk usage (df, du), viewing running processes (ps), setting aliases (alias), changing user identity (su, sudo), viewing command history (history), setting the system date and time (date), displaying calendars (cal), and clearing the terminal screen (clear). It provides the syntax and examples for using each command.
This document provides an introduction to multiprocessor systems. It describes how multiprocessor systems use multiple processors together to improve performance and speed over uniprocessor systems. Multiprocessor systems can be tightly or loosely coupled. Tightly coupled systems share memory and communication while loosely coupled systems use separate processors connected via a network. The document discusses different interconnection techniques for multiprocessors like bus-oriented, crossbar, and multistage switching systems. It also covers multiprocessor operating systems and their functions in supporting parallel processing across CPUs.
This document discusses an Android application for a Sudoku game and its relation to the Android operating system. It first defines Android as a software stack including an OS, middleware and apps. It then explains that an Android app is designed to run on Android devices like smartphones and tablets. It describes the Sudoku game app the presenter created for Android, including difficulty settings and options for sounds and hints. It outlines the four layers of the Android OS - the Linux kernel, libraries and runtime, application framework, and applications. It discusses how the Sudoku app uses specific libraries and components from the Android framework like SQLite for data storage, the 2D graphics library, and the activity manager.
Android is an open source software platform for mobile devices based on the Linux kernel. It includes APIs for app development, core applications like email and maps, and services like notifications and activity management. At its core are the Dalvik virtual machine, C/C++ libraries, and underlying Linux system functionality that allow Android to run efficiently on various hardware configurations and platforms.
The document discusses clients and servers, middleware, and different types of client-server architectures. It provides definitions and examples of clients, servers, middleware, fat clients, fat servers, 2-tier architectures, and 3-tier architectures. It also compares characteristics and advantages of 2-tier vs 3-tier architectures.
This document provides an introduction to object-oriented programming and Java. It discusses the basics of OOP concepts like classes, objects, encapsulation, inheritance, polymorphism and dynamic binding. It explains the benefits of OOP like modularity, code reuse and information hiding. The document also outlines some key features of the Java programming language like platform independence, security, simplicity and performance. It positions Java as a pure object-oriented language suitable for developing both standalone applications and web applets.
The document provides tutorials for various user interface widgets in Android application development. It includes tutorials for date pickers, time pickers, spinners, buttons, text fields, checkboxes, radio buttons, toggle buttons, and rating bars. Each tutorial section describes how to add the widget to an app layout, populate it with data where applicable, and add click listeners or other logic to handle user interactions with the widget. The tutorials are intended to demonstrate how to correctly implement and use common UI elements in Android apps.
This presentation is about the introduction, history and inner supporting managing system of Operating System.
how Process Scheduling and file management works by Windows.
Tk2323 lecture 1 introduction to mobile applicationMengChun Lam
The document provides an introduction to a mobile application development course. It outlines topics that will be covered including Android architecture, mobile development considerations like device fragmentation and limited resources, and different app development methods like native, hybrid and web apps. It also introduces key mobile platforms like Android and iOS and how apps are distributed for each.
A short explanation of Architecture of operating system. In this slide i explain about monolithic OS , layer OS, microkernel OS and networked and distributed OS with their architecture.
An Android application is composed of activities, services, and content providers. Activities display user interfaces and are launched by intents. The context provides access to application-wide resources and functionality. Activities have a lifecycle of states like resumed, paused, and stopped that are called back through methods to manage resources. Intents are used to transition between activities within an app or launch other apps' components.
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiSowmya Jyothi
Unix is a multitasking, multiuser operating system developed in 1969 at Bell Labs. It allows multiple users to use a computer simultaneously and users can run multiple programs at once. There are several Unix variants like Solaris, AIX, and Linux. Unix was originally written for the PDP-7 computer in C programming language, making it portable. It uses a hierarchical file system and treats all resources as files with permissions. Processes run programs and the shell interprets commands to run programs or interact with the kernel for system calls. Everything in Unix is either a file or a process.
This document discusses process management in Android. It describes how Android applications run in processes and the different application components like activities, services, broadcast receivers, and content providers. It covers the process lifecycle and importance hierarchy. It also discusses threads, inter-process communication, deadlock handling, and the CPU scheduling policy in Android, including completely fair scheduling, nice values, control groups, schedtune, and cpuset.
Threads handlers and async task, widgets - day8Utkarsh Mankad
This document discusses processes and threads in Android, process lifecycles, thread management principles, and how to create and manage widgets in Android. It covers the following key points:
- Processes and threads in Android and how the main thread handles UI events.
- The 5 levels of importance for application processes and when processes are killed.
- Using handlers and AsyncTasks to perform background work without blocking the UI thread.
- The basics of widgets including the AppWidgetProviderInfo, AppWidgetProvider class, and layout.
- The steps to create a widget including declaring it in the manifest, metadata, layouts, provider class, and configuration activity.
Analysis Of Process Structure In Windows Operating SystemDarian Pruitt
This document analyzes the process structure in the Windows operating system. It discusses how Windows handles programs differently than other operating systems. It explains the key components of a process in Windows including the private virtual space, executable sub-process, list of open handles, security context, process ID, and list of threads. It describes the different types of processes in Windows including user processes, service processes, system processes, and environment subsystem server processes. It also discusses the process table and u-area that contain important information about each process, such as the process state, memory locations, user IDs, timers, I/O parameters, and more. This information allows the kernel to manage processes and their execution.
The document discusses processor management in operating systems. It explains that operating systems must ensure each process receives enough processor time while using processor cycles efficiently. A process is a unit of software that can be controlled by the user, other applications, or the operating system. In single-tasking systems, the operating system allows one application to run at a time, suspending it for interrupts. In multi-tasking systems, the operating system rapidly switches between processes to give the appearance they are running simultaneously. It does this by allocating CPU time to each process and saving/loading their register, stack, and queue states.
The document discusses processes and process scheduling in an operating system. It defines a process as the basic unit of work in a system that progresses sequentially. A process control block (PCB) tracks information for each process like its ID and state. Processes can be created through system calls and terminate through exit calls. Scheduling algorithms like short-term, long-term, and medium-term are used to allocate CPU time to ready processes and swap processes in and out of memory. Preemptive and non-preemptive scheduling approaches differ in how they allocate CPU time to processes.
The document discusses operating system services and functions. It describes that an operating system manages computer resources, provides services for programmers, and schedules program execution. It then lists and describes key operating system services like program creation, execution, I/O access, file access, error handling, and accounting. The document also discusses how the operating system acts as a resource manager and describes common types of operating systems, scheduling, memory management techniques like swapping and paging, and how logical addresses are mapped to physical addresses.
There are four main types of application components in Android: activities which represent a single screen in the app, services which run in the background, broadcast receivers which allow the app to respond to system-wide events, and content providers which manage shared app data. The manifest file declares these components and their permissions. The activity lifecycle handles navigating between activities, saving and restoring state, and sending data between components within and between processes.
This document discusses operating systems, including what they are, their features and uses, and types of operating systems. It begins by defining an operating system as an interface between users and hardware that allows convenient and efficient usage of resources while protecting information. It then discusses key operating system functions like scheduling, memory management, and resource allocation. Finally, it outlines several types of operating systems including real-time, multi-user, multi-tasking, distributed, templated, and embedded operating systems.
The document discusses the history and evolution of operating systems from early serial processing systems through batch processing, multiprogramming, and time-sharing systems. It describes how early systems had no operating system, requiring users to reserve computer time slots in advance. Later batch systems used a monitor program to process multiple jobs sequentially. Multiprogramming and time-sharing systems allowed concurrent execution of multiple programs to improve processor utilization but introduced challenges around memory organization and scheduling. The document also discusses system calls and interrupt processing.
This is my sort note of operating system.In this note we describe our knowledge for B.Sc level. Student of B.Sc(H) Computer Science this note is good. We describe this note very easy language which the student easily understand.
Advanced computer architecture lesson 1 and 2Ismail Mukiibi
An OS is a program that controls the execution of application programs and acts as an interface between the user of a computer and the computer hardware. .....................
The document provides an overview of operating system concepts and functions. It discusses that an operating system manages computer hardware resources and provides common services for computer programs. It then describes some key functions of an operating system including memory management, processor management, device management, file management, and other services like security and error detection. The document also covers different types of operating systems such as batch, time-sharing, distributed, network, and real-time operating systems.
This document provides an overview of key concepts in Android development including:
- Android components like Activities, Fragments, Services, etc.
- The application and activity lifecycles and how activities can move between states like active, paused, and stopped.
- Common Android development tools and how to structure an Android project with activities, fragments, and other components.
- Basic Android app architecture including the Linux kernel, Java framework layers, and how apps are packaged as APK files.
The document discusses operating systems and processes. It defines an operating system as software that controls hardware and manages resources. A process is a program in execution that has a unique ID and state. Processes go through various states like running, ready, blocked/waiting, and terminated. Threads are lightweight processes that can be scheduled independently and share resources within a process. User-level threads are managed in libraries while kernel-level threads are managed by the operating system kernel.
The document discusses operating systems and processes. It defines an operating system as software that controls hardware and manages resources. A process is a program in execution that has a unique ID and state. Processes go through various states like running, ready, blocked/waiting, and terminated. Threads are lightweight processes that can be scheduled independently and share resources within a process. User-level threads are managed in libraries while kernel-level threads are managed by the operating system kernel.
This document provides an overview of operating systems. It defines an operating system as a program that acts as an interface between the user and computer hardware to control execution of programs. The document then describes key functions of operating systems like memory management, processor management, device management, file management, and security. It also outlines different types of operating systems including batch, time-sharing, distributed, network, and real-time operating systems.
This document discusses processes and process management. It covers key concepts like process states, process scheduling, and inter-process communication. The main points covered are:
- A process is a program in execution that needs resources like CPU time, memory, and I/O devices. The operating system is responsible for process management tasks like creation, scheduling, and synchronization.
- Processes go through various states like new, ready, running, waiting, and terminated. Each process is represented by a process control block containing its state and resource allocation information.
- The CPU scheduler selects processes from ready queues to load into memory and execute. Scheduling algorithms aim to maximize CPU usage and provide fair access to processes.
An operating system acts as an interface between software and hardware, managing computer resources and monitoring program execution. It provides a user-friendly interface to utilize hardware in a concealed manner. Common operating systems include Windows, Linux, and UNIX. An operating system performs tasks like memory management, processor allocation, device management, file management, and security. Operating systems can be classified as batch, multiprogramming, time-sharing, real-time, multitasking, and multiprocessing based on their design and capabilities.
This presentation on Android OS contains basic and core concepts of Android Operation System, like Android Architecture, Dalvik Virtual Machine, Process Management, Memory Management, Application and Service life cycle, etc...
Similar to Tk2323 lecture 11 process and thread (20)
This document provides an overview of sensors on Android devices. It discusses categories of sensors including motion, environmental, and position sensors. It describes the Android sensor framework and types of sensors such as accelerometers, gyroscopes, gravity sensors, and rotation vectors. It provides details on accessing sensor data and best practices for using sensors. Specific sensors like temperature, humidity, and ambient light sensors are explained.
This document provides an overview of JSON and APIs for mobile programming. It defines JSON data types like numbers, strings, booleans, arrays and objects. It then explains the concept of APIs including endpoints, parameters, methods and status codes. It demonstrates making API requests from Android apps using the Volley library, including examples of GET requests without data, POST requests with data in the body, and DELETE requests with data in the URL. Code samples are provided for each type of request.
This document discusses user interface (UI) and user experience (UX) design considerations for mobile applications. It begins with an overview of simple list views and adapters in Android. It then covers several key constraints for mobile UX design, including limited data, finite battery life, hand-held usage, divided user attention, and small screens. The document provides tips for UI design on mobile, including formatting content, text size and spacing, touch controls, and hit targets. It also discusses list views and master-detail views in more detail. Overall, the document outlines important factors to consider for optimizing the mobile user experience.
This document provides information about fragments in Android. It defines a fragment as a modular section of an activity that has its own lifecycle and can be reused across activities. The key points covered include:
- Fragments have their own lifecycle that is directly tied to the host activity's lifecycle.
- The fragment lifecycle involves creation, view creation, attachment/detachment from the activity, and destruction phases.
- Fragments can be added to activities either statically in XML layouts or dynamically at runtime using FragmentTransactions.
- Fragments communicate with their host activity using getActivity() and the activity can reference fragments via the FragmentManager.
The document discusses various options for storing data in Android applications, including SharedPreferences, SQLite databases, network connections, content providers, and internal/external storage. It provides details on each option, such as what type of data each is suited for and how private or public the data is. Examples are given of storing data in SharedPreferences using key-value pairs and retrieving the data. The document also covers SQLite databases and using SQL to query and manipulate structured data.
Tk2323 lecture 5 material design & recycler viewMengChun Lam
This document provides an overview of Material Design and RecyclerView for Android development. It discusses key concepts of Material Design including environment, material properties, elevation and shadows. It also outlines the steps to construct a custom list using RecyclerView, including defining data models, view holders, and an adapter to link data to views. The RecyclerView displays large data sets efficiently by maintaining a limited number of views.
This document provides an outline and overview of key concepts for working with databases and SQL in mobile programming. It discusses different types of databases like SQLite and concepts like tables, rows, columns, and basic SQL statements for creating tables, selecting, inserting, updating, and deleting data. Examples are provided for each SQL statement to demonstrate their proper syntax and usage.
The document discusses intents, broadcast receivers, and intent filters in Android. It provides examples of explicit intents that specify a component directly and implicit intents that declare an action without specifying a component. Implicit intents can be received by components that declare intent filters supporting the action, MIME type, and category. The document also discusses using intent filters in the app manifest to advertise which implicit intents an app's activities, services, and broadcast receivers can receive.
This document provides an overview of user interface concepts in Android mobile app development, including:
- Common layouts like LinearLayout, RelativeLayout, and ConstraintLayout.
- Attributes for configuring views and view groups, such as width, height, padding, gravity.
- Best practices for supporting multiple screen densities and orientations using density-independent pixels and qualifiers.
- The process of declaring UI elements in XML layout files and linking them to code.
4. Process
▹When an application component starts and the
application does not have any other components
running, the Android system starts a new Linux
process for the application with a single thread of
execution.
▹By default, all components of the same application
run in the same process and thread (called the "main"
thread/ UI thread).
4
5. Process
▹If an application component starts and there
already exists a process for that application (because
another component from the application exists), then
the component is started within that process and
uses the same thread of execution.
▹However, you can arrange for different components
in your application to run in separate processes, and
you can create additional threads for any process.
5
7. Process
A new Linux process for the application with a single thread of execution
7
8. Process
▹By default, all components of the same application
run in the same process and most applications should
not change this.
▹However, if you find that you need to control which
process a certain component belongs to, you can do
so in the manifest file.
8
9. 9 Processes
▹The manifest entry for each type of component element—
<activity>, <service>, <receiver>, and <provider> —supports
an android:process attribute that can specify a process in
which that component should run.
▹You can set this attribute so that each component runs in
its own process or so that some components share a process
while others do not.
10. 10 Processes
▹You can also set android:process so that components of
different applications run in the same process—provided
that the applications share the same Linux user ID and are
signed with the same certificates.
12. 12 Processes
▹Android might decide to shut down a process at some
point, when memory is low and required by other
processes that are more immediately serving the user.
▹Application components running in the process that's
killed are consequently destroyed.
▹A process is started again for those components when
there's again work for them to do.
13. 13 Processes
▹The Android system tries to maintain an application
process for as long as possible, but eventually needs to
remove old processes to reclaim memory for new or more
important processes.
14. 14 Processes
▹To determine which processes to keep and which to kill,
the system places each process into an "importance
hierarchy" based on the components running in the process
and the state of those components.
▹Processes with the lowest importance are eliminated first,
then those with the next lowest importance, and so on, as
necessary to recover system resources.
16. 16
Processes: Foreground
Process
▹A process that is required for what the user is currently doing.
▹It hosts an Activity that the user is interacting with (the Activity's
onResume() method has been called).
▹It hosts a Service that's bound to the activity that the user is
interacting with.
▹It hosts a Service that's running "in the foreground"—the
service has called startForeground().
17. 17
Processes: Foreground
Process
▹A process that is required for what the user is currently
doing.
▹Various application components can cause its containing
process to be considered foreground in different ways.
18. 18
Processes: Foreground
Process
▹It is running an
Activity at the top of
the screen that the user
is interacting with (its
onResume() method
has been called).
▹It has a
BroadcastReceiver that
is currently running (its
BroadcastReceiver.onR
eceive() method is
executing).
▹It has a Service that is
currently executing
code in one of its
callbacks
(Service.onCreate(),
Service.onStart(), or
Service.onDestroy()).
▹A process is considered to be in the foreground if any of
the following conditions hold:
20. 20 Processes: Visible Process
▹A visible process is doing work that the user is currently
aware of, so killing it would have a noticeable negative
impact on the user experience.
▹A visible process is considered extremely important and
will not be killed unless doing so is required to keep all
foreground processes running.
21. 21 Processes: Visible Process
▸It is running an Activity
that is visible to the user
on-screen but not in the
foreground (its onPause()
method has been called).
This may occur, for
example, if the foreground
Activity is displayed as a
dialog that allows the
previous Activity to be
seen behind it.
▹It has a Service that is
running as a foreground
service, through
Service.startForeground()
(which is asking the
system to treat the service
as something the user is
aware of, or essentially
visible to them).
▸It is hosting a service
that the system is using
for a particular feature
that the user is aware (live
wallpaper, input method
service, etc.)
▹A process is considered foreground in the following
conditions:
22. 22 Processes: Service process
▹A process that is running a service that has been started with
the startService() method and does not fall into either of the two higher
categories.
▸User is not directly interacting
▹Although service processes are not directly tied to anything the user
sees, they are generally doing things that the user cares about (such as
playing music in the background or downloading data on the network),
▹so the system keeps them running unless there's not enough memory
to retain them along with all foreground and visible processes.
23. 23 Processes: Service process
▹Services that have been running for a long time (such as
30 minutes or more) may be demoted in importance to
allow their process to drop to the cached Least Recently
Used (LRU) list described next.
▹This helps avoid situations where very long running
services with memory leaks or other problems consume so
much RAM that they prevent the system from making
effective use of cached processes.
24. 24 Cached Process
▹A cached process is one that is not currently needed, so
the system is free to kill it as desired when memory is
needed elsewhere.
▹In a normally behaving system, these are the only
processes involved in memory management: a well running
system will have multiple cached processes always available
(for more efficient switching between applications) and
regularly kill the oldest ones as needed.
25. 25 Cached Process
▹These processes often hold one or more Activity instances that are not
currently visible to the user (the onStop() method has been called and
returned).
▹Provided they implement their Activity life-cycle correctly (see Activity
for more details),
▹when the system kills such processes it will not impact the user's
experience when returning to that app:
▹it can restore the previously saved state when the associated activity is
recreated in a new process.
26. 26
Cached Process (LRU- Least
Recently Used_
▹These processes are kept in a pseudo-LRU list, where the
last process on the list is the first killed to reclaim memory.
▹The exact policy of ordering on this list is an
implementation detail of the platform, but generally it will
try to keep more useful processes (one hosting the user's
home application, the last activity they saw, etc) before
other types of processes.
27. 27
Cached Process (LRU- Least
Recently Used_
▹Other policies for killing processes may also be applied:
hard limits on the number of processes allowed, limits on
the amount of time a process can stay continually cached,
etc.
29. 29 Processes (Service Tips)
▹Because a process running a service is ranked higher than a process
with background activities, an activity that initiates a long-running
operation might do well to start a service for that operation, rather than
simply create a worker thread—particularly if the operation will likely
outlast the activity.
▹For example, an activity that's uploading a picture to a web site should
start a service to perform the upload so that the upload can continue in
the background even if the user leaves the activity.
▹Using a service guarantees that the operation will have at least
"service process" priority, regardless of what happens to the activity.
30. 30 Processes
▹Process running a service is ranked higher [as a Service
Process] than a process that doesn’t have a service [uses
threads for long running operations]
▹Hence, downloading an image from a worker thread using
a Service is better than downloading without a service.
33. 33 Threads
▹When an application is launched, the system creates a thread of
execution for the application, called "main“/ “UI” thread.
▹This thread is very important because it is in charge of
dispatching events to the appropriate user interface widgets,
including drawing events.
▹It is also the thread in which your application interacts with
components from the Android UI toolkit ( components from the
android.widget and android.view packages ).
34. 34 Threads
1. On certain occasions a single app may want to do more than one
‘thing’ at the same time. For instance, show an animation, download
a large file from a website, and maintain a responsive UI for the user
to enter data.
▸One solution is to have the app run those individual concurrent
actions in separate threads.
2. Threads are the smallest sequence of programmed instructions
that can be managed independently by operating system
3. They are units of computation that run simultaneously within a
process
35. 35 Threads
▹The system does not create a separate thread for each
instance of a component.
▹All components that run in the same process are
instantiated in the UI thread, and system calls to each
component are dispatched from that thread.
▹Consequently, methods that respond to system callbacks
(such as onKeyDown() to report user actions or a lifecycle
callback method) always run in the UI thread of the process.
36. 36
Threads
▹For instance, when the user touches a button on the screen, your
app's UI thread dispatches the touch event to the widget, which in
turn sets its pressed state and posts an invalidate request to the
event queue.
▹The UI thread dequeues the request and notifies the widget that
it should redraw itself.
Change the
color of the
text view
Touch
Button
Main Thread
37. 37 Threads
▹When your app performs intensive work in response to user
interaction, this single thread model can yield poor performance
unless you implement your application properly.
▹Specifically, if everything is happening in the UI thread,
performing long operations such network access, database
queries, complicated calculations, accessing big files will block
the whole UI.
▹When the Main thread is blocked, no events can be
dispatched, including drawing events. From the user's
perspective, the application appears to hang.
38. 38 Threads
▹Even worse, if the UI thread is blocked for more than a
few seconds (about 5 seconds currently) the user is
presented with the infamous “application not responding"
(ANR) dialog.
▹In practice, users will notice input delays and UI pauses of
more than a couple of hundred milliseconds.
▹The user might then decide to quit your application and
uninstall it if they are unhappy.
39. 39 Threads
Change the
color of the
text view
Touch
Button
Long
Running
Process
Touch
Button
Main Thread
Wait until the process complete running,
only then the UI will respond again.
(Button will not work until the process
has finished)
40. 40 Threads
Change the
color of the
text view
Touch
Button
Long
Running
Process
Touch
Button
Main Thread
Separated
Thread
Update Result after finish
running the process
42. 42 Threads
▹Additionally, the Andoid UI toolkit is not thread-safe. So, you
must not manipulate your UI from a worker thread—you must do
all manipulation to your user interface from the UI thread.
▹Thread-safe code is code that will work even if many Threads
are executing it simultaneously.
▹Thus, there are simply two rules to Android's single thread
model:
▸Do not block the UI thread
▸Do not access the Android UI toolkit from outside the UI
thread
43. 43
Worker or Background
threads
▹Because of the single thread model described above, it's
vital to the responsiveness of your application's UI that you
do not block the UI thread.
▹If you have operations to perform that are not
instantaneous, you should make sure to do them in separate
threads ("background" or "worker" threads).
46. 46
Example public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
}
});
}
47. 47
Example public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
// long running process
}
}).start();
}
48. 48 Example
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
Bitmap b =
loadImageFromNetwork("http://example.com/image.png");
mImageView.setImageBitmap(b);
}
}).start();
}
What’s wrong???
49. 49
Worker or Background
threads
▹To fix this problem, Android offers several ways to access
the UI thread from other threads. Here is a list of methods
that can help:
▸Activity.runOnUiThread(Runnable)
▸View.post(Runnable)
▸View.postDelayed(Runnable, long)
50. 50 Example
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
Bitmap b =
loadImageFromNetwork("http://example.com/image.png");
mImageView.setImageBitmap(b);
}
}).start();
}
What’s wrong???
51. 51
Worker or Background
threads
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
final Bitmap bitmap =
loadImageFromNetwork("http://example.com/image.png");
mImageView.post(new Runnable() {
});
}
}).start();
}
52. 52
Worker or Background
threads
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
final Bitmap bitmap =
loadImageFromNetwork("http://example.com/image.png");
mImageView.post(new Runnable() {
public void run() {
}
});
}
}).start();
}
53. 53
Worker or Background
threads
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
final Bitmap bitmap =
loadImageFromNetwork("http://example.com/image.png");
mImageView.post(new Runnable() {
public void run() {
mImageView.setImageBitmap(bitmap);
}
});
}
}).start();
}
54. 54
Worker or Background
threads
▹Activity.runOnUiThread(Runnable)
▸Runs the specified action on the UI thread.
▸If the current thread is the UI thread, then the action is
executed immediately.
▸If the current thread is not the UI thread, the action is
posted to the event queue of the UI thread.
67. 67
Worker or Background
threads: Using AsyncTask
▹This kind of code can get complicated and difficult to
maintain
▹AsyncTask allows you to perform asynchronous work on
your user interface.
▹It performs the blocking operations in a worker thread
and then publishes the results on the UI thread, without
requiring you to handle threads and/or handlers yourself.
68. 68
Worker or Background
threads: Using AsyncTask
▹AsyncTask is designed to be a helper class around Thread and
Handler and does not constitute a generic threading framework.
▹AsyncTasks should ideally be used for short operations (a few
seconds at the most.)
▹If you need to keep threads running for long periods of time, it is
highly recommended you use the various APIs provided by the
java.util.concurrent package such as Executor,
ThreadPoolExecutor and FutureTask.
69. 69
Worker or Background
threads: Using AsyncTask
▹An asynchronous task is defined by a computation that
runs on a background thread and whose result is published
on the UI thread.
70. 70
Worker or Background
threads: Using AsyncTask
▹Params,
▹the type of the
parameters sent to the
task upon execution.
▹Progress,
▹the type of the
progress units
published during the
background
computation
▹Result,
▹the type of the result
of the background
computation.
▹An asynchronous task is defined by 3 generic types, called
• Params,
• Progress
• Result
72. 72
Worker or Background
threads: Using AsyncTask
▹onPreExecute
▸invoked on the UI thread before the task is executed.
▸This step is normally used to setup the task, for
instance by showing a progress bar in the user interface.
▸Runs on the UI thread before
doInBackground(Params...)
73. 73
Worker or Background
threads: Using AsyncTask
▹doInBackground
▸invoked on the background thread immediately after
onPreExecute() finishes executing
▸This method will be executed on the background Thread, so place
your long-running code here, don’t attempt to interact with UI
objects within this handler.
▸It takes a set of parameter of the type defined in your class
implementation
▸You can use the publishProgress() method from within this handler
to pass parameter values to the onProgressUpdate() handler,
▸and when your background task is complete, you can return the
final result as a parameter to the onPostExecute() handler, which can
update the UI accordingly.
74. 74
Worker or Background
threads: Using AsyncTask
▹onProgreeUpdate
▸Override this handler to update the UI with interim
progress updates.
▸This handler receives the set of parameters passed in to
▸publishProgress (typically within the doInBackground
handler).
▸This handler is synchronized with the GUI Thread when
executed, so you can safely modify UI elements.
75. 75
Worker or Background
threads: Using AsyncTask
▹onPostExecute
▸When doInBackground() has completed, the return
value from that method is passed in to this event handler.
▸Use this handler to update the UI when your
asynchronous task has completed.
▸This handler is synchronized with the GUI Thread when
executed, so you can safely modify UI elements.
76. 76
private class DownloadFilesTask extends AsyncTask<Params, Progress, Result> {
protected void onPreExecute() {
// Runs on the UI thread before doInBackground()
}
protected Long doInBackground(Params... urls) {
// Perform an operation on a background thread
doSomethingLongRunning();
return something;
}
protected void onProgressUpdate(Progress... progress) {
// Runs on UI thread after publishProgress(Progress...) is invoked
// from doInBackground()
pb.setProgress(progress[0]));
}
protected void onPostExecute(Result result) {
// Runs on the UI thread after doInBackground()
showDialog("Downloaded " + result + " bytes");
}
}
77. 77 Example
params progress result
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
tv_status.setText(“Start downloading");
}
.
.
.
}
78. 78 Example
params progress result
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
Looping
{
DownloadPicture();
publishProgress((int)howManyHasDownloaded));
}
return totalNumberOfPic;
}
protected void onProgressUpdate(Integer... progress) {
tv_status.setText(“Downloading: ”+progress[0]));
}
protected void onPostExecute(Long result) {
tv_status.setText(“Downloaded " + result + " pic");
}
}
79. 79 Example
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
int count = urls.length;
long totalSize = 0;
for (int i = 0; i < count; i++) {
totalSize += Downloader.downloadFile(urls[i]);
publishProgress((int) ((i / (float) count) * 100));
// Escape early if cancel() is called
if (isCancelled()) break;
}
return totalSize;
}
protected void onProgressUpdate(Integer... progress) {
tv_status.setText(progress[0]));
}
protected void onPostExecute(Long result) {
showDialog("Downloaded " + result + " bytes");
}
}
80. 80
Worker or
Background
threads:
AsyncTask
▹AsyncTask is not bonded to the activity
life cycle
▹The virtual machine will hold on the
activity object as long as the AsyncTask is
running
▹AsyncTask is running even the activity is
destroyed
▹Thus there is a chance multiple
AsyncTask is running in the same time
▸Portrait
▸Landscape
▹Not suitable for the long running
operation (>few seconds)
▹Use service instead
Activity Async Task
82. 82 Introduction
▹Android maintains a MessageQueue (message loop) on the main thread which
basically contains a list of Messages or Runnables (set of executable code) that the
Looper dispatches to appropriate Handlers.
▹When a process is created for your application, its main thread is dedicated to
running a message queue that takes care of managing the top-level application
objects (activities, broadcast receivers, etc) and any windows they create.
▹You can create your own threads, and communicate back with the main application
thread through a Handler. This is done by calling the
same post or sendMessage methods, but from your new thread.
▹The given Runnable or Message will then be scheduled in the Handler's message
queue and processed when appropriate.
83. 83
Message Queue
Looper, Handler, Message
Queue
message message message message
Looper
message
Looper
message
Handler
Looper
message
Looper contain message and
associated with the Message
Queue. So it could be run
into the thread
Handler contain
looper
Handler determine when it should dispatch the
message into the message queue and execute them
as they come out of the message queue.
postAtTime(Runnable, long)…
84. 84 Handler
▹A Handler allows you to send and process Message and
Runnable objects associated with a thread's MessageQueue.
▹Each Handler instance is associated with a single thread and
that thread's message queue.
▹When you create a new Handler, it is bound to the thread /
message queue of the thread that is creating it -- from that point
on, it will deliver messages and runnables to that message queue
and execute them as they come out of the message queue.
85. 85 Handler
▹There are two main uses for a Handler:
▸(1) to schedule messages and runnables to be executed
as some point in the future; and
▸(2) to enqueue/add an action to be performed on a
different thread than your own.
86. 86 Handler
▹When posting or sending to a Handler, you can either
allow the item to be processed as soon as the message
queue is ready to do so, or specify a delay before it gets
processed or absolute time for it to be processed.
▸post(Runnable)
▸postAtTime(Runnable, long)
▸postDelayed(Runnable, long)
▸Handler.post...
87. 87 MessageQueue
▹Low-level class holding the list of messages to be
dispatched by a Looper to the Handlers.
▹Messages are not added directly to a MessageQueue, but
rather through Handler objects associated with the Looper.
▹MessageQueue (message loop) on the main thread which
basically contains a list of Messages or Runnables (set of
executable code) that the Looper dispatches to appropriate
Handlers.
88. 88 Looper
▹Class used to run a message loop for a thread.
▹The main thread is a message loop and has a looper.
▹Threads by default do not have a message loop associated with
them; to create one, call prepare() in the thread that is to run the
loop, and then loop() to have it process messages until the loop is
stopped.
▹Most interaction with a message loop is through the Handler
class.
89. 89 Example
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
Looper.loop();
}
}