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

android studio tutorial 2

Uploaded by

Fazilah K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

android studio tutorial 2

Uploaded by

Fazilah K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EXECUTIVE DIPLOMA

IN INFORMATION TECHNOLOGY

TUTORIAL 2 (WEEK – 2)

COURSE CODE : UFH2011


COURSE TITLE : Mobile Application Development
STUDENT NAME : SITI FAZILAH BINTI KASIM
MATRIC NUMBER : UFH220033
LECTURER : Prof. Dr. Ong Sim Ying
TUTORIAL 2 QUESTIONS

1. Explain the importance of Sandbox mechanism in Android System.

Sandbox mode in Android is a security feature that keeps apps isolated from each other and
the system to improve security and stability. Each app runs within its own "sandbox" or
isolated environment, preventing it from accessing data or resources of other apps unless it’s
explicitly allowed. Here’s a breakdown of how Android’s sandboxing works:

Isolation: Each app operates in its own environment, which prevents malicious apps from
easily accessing sensitive data from other apps.

Permissions: Apps must request specific permissions to access certain features or data, such
as the camera, contacts, or location. Users can grant or deny these permissions.

User Data Protection: Sandboxing helps protect user data by ensuring that apps cannot read
or write to each other's storage without permission.

Resource Management: The Android operating system allocates system resources to apps
based on their needs, helping to manage performance and battery life.

Security Benefits: By running apps in isolated environments, Android reduces the risk of
malware and other security threats, as a compromised app is limited in what it can do.
Overall, sandbox mode is a fundamental part of Android's security model, helping to create a
safer user experience.
- Access Control
- to prevent application from tempering with each other.
- shared data
- process/processing/memory
- to prevent unauthorized access to data/resources/harware in the system

- Prepare testing environment - good for testing.


2. Explain using your own words, the six core callback methods in activity lifecycle.

OnCreate()

This is the initial method that runs when an activity starts. It’s where you prepare everything the
activity needs, such as setting up the user interface and loading initial data. Since it only runs once
during the activity’s lifecycle, it’s perfect for setup tasks that only need to happen once.

OnStart()

After OnCreate(), this method is called to make the activity visible to the user. It prepares the activity
to enter the foreground, getting it ready for user interaction. This is where you might set up or
refresh UI elements.
OnResume()

At this point, the activity is fully active and ready for user interaction. The app is now in the
foreground, and the user can engage with it directly. The activity stays in this state until something
else takes focus, like an incoming call or the user switching to another app.

OnPause()

This is the first indication that the user is moving away from the activity, even if temporarily. It’s a
brief method intended for light tasks, like pausing animations or saving temporary data. The activity
is still partly active but no longer the main focus.

OnStop()

This method is called when the activity is no longer visible to the user, either because a new activity
has fully covered it or because it’s closing. It’s a good place to release resources or save persistent
data, as the activity may return but is not actively visible.

OnDestroy()

This final method is triggered before the activity is completely removed from memory. It’s where you
should complete any last cleanup tasks. OnDestroy() is called either when the activity is finishing for
good or if the system needs to temporarily destroy it due to configuration changes, like screen
rotation.
3. Identify the four Android App components and briefly explain each of them. Then, give one
example event that matches the components.
1) Activity
a. Services
 Services is a background component that runs independently of the user interface, it
allows tasks to continue running in the background (even if the user switches to
another app).
 Services is ideal to perform long-running operation and also to perform work for
remote process.
 Service has no user interface.
 Example of Services : Music streaming app, live wallpaper, notification listener, etc.

b. Broadcast receiver
 Broadcast receiver is a component that deliver the events to the app outside of a
regular user flow.
 It allowing the app to response to the system-wide broadcast announcement, such
as change in network connectivity, battery status, or incoming messages.
 It also can deliver the broadcast to the app that are currently not running.
 Broadcast receiver does not display full user interface, but may create status bar
notification.
 Normally it acts as gateway to other components.

c. Content provider
 Content provider manages a shared set of app data that you can stored in a file
system / SQLite database / on web / any persistent storage location.
 It allows different app to share data securely, like contacts or images, while enforcing
data access permissions.
 For example, the Contact App uses a content provider to manage and share contact
data enabling other apps to access conract information when permission is granted.

d. Activating component
 Activating component consist of “Intent” and “Content Resolver”.
 In order to use Android System, user need to deliver a message to the system that
specifies the user “Intent” to start a particular component, system will then activate
the component for the user.
 An asynchronous message utilized to activate activity, service and broadcast receiver.
 It acts as messenger that request an action from other components, whether the
component is belong to y our app or not.
 “Content Resolver” handle all direct transactions with content provider.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy