KEMBAR78
MADT | PDF | Android (Operating System) | Mobile App
0% found this document useful (0 votes)
57 views9 pages

MADT

The document provides an overview of various Android development concepts, including UI thread management, adapters, event handling, mobile operating systems, storage options, application components, and services. It also covers Android's architecture, fragments, notifications, and the use of PhoneGap for cross-platform development. Additionally, it explains the lifecycle of activities and fragments, as well as the importance of the AndroidManifest.xml file.

Uploaded by

katetanmay5115
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)
57 views9 pages

MADT

The document provides an overview of various Android development concepts, including UI thread management, adapters, event handling, mobile operating systems, storage options, application components, and services. It also covers Android's architecture, fragments, notifications, and the use of PhoneGap for cross-platform development. Additionally, it explains the lifecycle of activities and fragments, as well as the importance of the AndroidManifest.xml file.

Uploaded by

katetanmay5115
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/ 9

1) runOnUiThread

Purpose: Android enforces that only the main (UI) thread can make changes to UI
components. When background threads perform long tasks you must use runOnUiThread()
to update the UI safely. Useful when you're using Thread, AsyncTask, or any background
worker and need to update UI elements like TextView, ProgressBar, etc. Directly updating UI
from a background thread can crash the app due to CalledFromWrongThreadException.

2) Adapters
Definition: Adapters act as a bridge between the data source (like arrays, database, or API)
and UI components (like ListView, GridView, RecyclerView).
Function: Takes data and converts it into views. Manages how each item in a list/grid should
look and behave. Types of Adapters:
1)ArrayAdapter – for lists backed by an array or list.
2)BaseAdapter – a customizable adapter used for complex layouts.
3)CursorAdapter – connects data from SQLite databases.
4)RecyclerView.Adapter – used with RecyclerView, provides better performance for lists.

3) Event Handling in Android


Definition: Mechanism that lets the app respond to user interactions like button clicks, screen
touches, swipes, etc.
Event Listeners: Interfaces used to capture events. Common listeners include:
OnClickListener – handles click events.
OnTouchListener – handles touch gestures.
OnLongClickListener – for long presses.
OnKeyListener – for key press events.
Custom Events: Developers can create custom event listeners to handle app-specific
interactions.
Importance: Helps make apps interactive and responsive to user input.

4) Explain various types of Mobile OS. Differentiate them


There are several mobile operating systems, with unique characteristics and use cases.
1)Android : -Open-source, based on Linux. Most popular mobile OS.
-Customizable, supports Google Play Store and third-party apps.
2)iOS : -Developed by Apple for iPhones and iPads.
-Closed-source, known for security, performance, and smooth UI.
3)HarmonyOS : -Developed by Huawei as an alternative to Android.
-Supports cross-device app development (phones, TVs, IoT).
4)KaiOS : -Lightweight OS based on Linux, used in feature phones.
-Supports basic apps and internet connectivity.
5)Windows Phone (discontinued) : -Developed by Microsoft. Failed due to lack of app
support.
5) Write short note on storage in Android
Android offers several types of data storage options to suit different use cases:
SharedPreferences – Used for storing simple key-value pairs, such as user settings or login
Internal Storage – Saves files in the app’s private directory. These files are secure and not
accessible by other apps.
External Storage – Used for storing large or user-generated files like images and videos.
Needs runtime permissions from Android 6.0 onwards.
SQLite – A lightweight relational database available on the device. Used for structured data
storage and allows SQL queries.
Room Database – An abstraction layer over SQLite that simplifies database operations and
supports data binding, LiveData, and more.
Each option has its purpose depending on data sensitivity, size, and scope.

6) What are the Components of an Android Application? Explain all


Android apps are built using four main components. These components interact with the
user, system, and each other to deliver app functionality:
Activity – Represents a single screen with a user interface. Manages user interactions. For
example, a login screen is an activity.
Service – Runs long-running operations in the background without user interface, such as
playing music or downloading files.
BroadcastReceiver – Listens for and responds to system-wide broadcast announcements
like battery low, Wi-Fi state, etc.
ContentProvider – Manages access to structured data (e.g., contacts, media) and allows
sharing of data between apps.
In addition, every Android app has an AndroidManifest.xml file where these components are
declared, along with app permissions and metadata.

7) Explain alarm
In Android, an alarm is used to schedule tasks or events to occur at a specific time in the
future, even if the app is not running or the device is idle. This is done using the
AlarmManager system service.
Purpose: Alarms are mainly used for operations that need to be executed at a particular time
or interval, such as:
-Triggering a notification at a set time
-Scheduling periodic background tasks
-Running a daily reminder or alarm clock feature
Key Classes Involved:
AlarmManager – Schedules the alarm.
PendingIntent – Describes the action to perform (such as launching a broadcast or service).
BroadcastReceiver – Receives the alarm and executes the required code.
Alarms are a powerful tool to execute tasks on time, especially in the background, even
when the app is not active.

8) Explain Toast with example


A Toast in Android is a small message that pops up on the screen to provide feedback to the
user. It automatically fades in and out and does not require user interaction. It is mostly used
for short messages like "Data saved", "No Internet", etc.
Example: Toast.makeText(this, "Login successful", Toast.LENGTH_LONG).show();
9)What is thread? Explain the use of AsyncTask class
A thread is a lightweight process that allows concurrent execution of tasks. In Android, the
main thread (also called the UI thread) handles user interface operations. Performing long
operations (like network calls) on the main thread can freeze the UI or cause ANR
(Application Not Responding) errors. To avoid this, Android provides background threading
options like AsyncTask (deprecated in API level 30 but still useful in understanding legacy
code). AsyncTask allows background operations to be executed and results to be published
on the UI thread without directly managing threads.

9) Write an Android Program to print addition of two numbers


EditText e1, e2;
TextView result;
Button add;
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int num1 = Integer.parseInt(e1.getText().toString());
int num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 + num2;
result.setText("Sum: " + sum);
}
});
This code takes two numbers from input fields and shows their sum when button is clicked.

10) Explain activity life cycle in detail


The activity life cycle is a sequence of states an activity goes through from creation to
destruction. Managing this properly ensures app stability and performance.
onCreate() – Called when the activity is first created. Use this to initialize views, variables,
and start logic.
onStart() – Called when the activity becomes visible to the user.
onResume()- Called when the activity becomes interactive. The user can now interact with it.
onPause() – Called when another activity partially covers the current one. Use this to pause
tasks like animations or saving unsaved data.
onStop() – Called when the activity is no longer visible. Release resources or stop
background tasks here.
onRestart() – Called when the activity is coming back to the foreground after being stopped.
onDestroy() – Called when the activity is finishing or being destroyed by the system.

11) What is Broadcast Receiver?


A BroadcastReceiver is an Android component that listens for and responds to system-wide
broadcast messages or intents sent by the system or other apps. It does not display a UI but
reacts to events like: Battery low, Airplane mode changed, Incoming call or SMS.

12) Explain accelerometer


An accelerometer is a built-in hardware sensor in Android devices that measures the
acceleration applied to the device on all three axes (x, y, z). It is mainly used to:
Detect motion and gestures, Track orientation (portrait/landscape),
Monitor steps in fitness apps.
13) What is mobile App? Explain various types of mobile Apps
A mobile app is a software application designed to run on mobile devices like smartphones
and tablets. It provides various features such as social networking, productivity, games, etc.
Types of Mobile Apps:
1)Native Apps : Built for a specific platform using its native language (Java/Kotlin for
Android, Swift for iOS). -Fast and optimized for device features.
Example: WhatsApp, Instagram.
2)Web Apps : Accessed via a browser; not installed on the device. Built using HTML, CSS,
JavaScript. Example: Gmail Web.
3)Hybrid Apps : Built using web technologies but run inside a native container.
Cross-platform development. Example: Twitter, Uber (partially).
Each type has trade-offs in performance, development time, and cost.

14) What is Android Service? Explain types of services with example


A Service in Android is a component that performs long-running operations in the
background without a user interface. It is useful for tasks such as playing music, uploading
files, or handling network operations.
Types of Android Services:
1)Started Service: -Called using startService(). -Runs indefinitely until stopped.
Example: Background music player.
2)Bound Service: -Bound to an activity using bindService(). -Provides a client-server
interface. Example: Download service that reports progress.
3)Foreground Service: -Shows a persistent notification. -Used for tasks that should not be
killed by the system. Example: Fitness tracking app or music player.
4)IntentService (Deprecated): -Subclass of Service that handles asynchronous requests.
-Automatically stops after work is done.

15) What is ViewGroup class? Explain any 4 in detail


A ViewGroup is a container that holds multiple views or other ViewGroups and defines their
layout structure.
LinearLayout : Arranges child views in a single column (vertical) or row (horizontal).​
Uses weight and gravity for alignment.
RelativeLayout : Positions views relative to each other or the parent layout.​
Offers more flexibility than LinearLayout for complex UIs.​
FrameLayout : Used to hold a single view or stack multiple views on top of each other.​
Common for overlays or fragments.​
ConstraintLayout : Advanced and flexible layout. Positions views based on constraints
relative to other views or parent. Reduces the need for nested layouts.​
Each ViewGroup helps organize UI elements efficiently and contributes to performance and
readability.

16) What is View – In Android, a View is the basic building block for user interface (UI)
components. It represents a rectangular area on the screen and is responsible for drawing
and event handling.

17) Explain the term Android Fragment. – A Fragment is a modular section of an activity,
which has its own lifecycle, UI, and logic. Fragments enable more flexible UI designs,
especially on tablets, and allow reuse of UI components across multiple activities.
18) Write a short note on Android Content Providers
Content Providers manage access to structured data and allow sharing of data between
apps.They encapsulate data and provide it to other applications through a standard
interface. Examples: Contacts, Messages, Images, and Media files.
Key Components:
-ContentProvider class – Must be extended to create a custom provider.
-ContentResolver – Used by client applications to query or modify data.
-URI – Identifies the data to be accessed (e.g., content://contacts/people).
Basic Operations: query() – Read data, insert() – Add data,
update() – Modify existing data, delete() – Remove data
Use Cases:
-Sharing data between apps
-Secure data access control
-Syncing with remote servers
Content Providers are essential when apps need to provide or consume data beyond their
own boundaries.

19) What is Android OS? Explain its architecture in detail


Android OS is an open-source mobile operating system developed by Google. It is based on
the Linux kernel and designed primarily for touchscreen devices like smartphones and
tablets. Architecture of Android OS:
1)Linux Kernel : Core of the system that handles low-level operations like memory, power,
and process management.
2)Libraries and Android Runtime : C/C++ libraries like SQLite, WebKit, and SSL.
Android Runtime includes the ART (Android Runtime) and core Java libraries.
3)Application Framework : Provides high-level building blocks for apps like Activity
Manager, Content Providers, View System, etc.
4)Applications : This layer includes built-in apps (like phone, contacts) and user-installed
apps. All run in their own sandboxed environment.

20) Explain PhoneGap Plug-Ins. Explain steps to publish a plugin to npm


PhoneGap plugins are custom extensions that allow a web-based PhoneGap/Cordova app
to access native device capabilities (e.g., camera, contacts, GPS).
Plugins consist of:
-JavaScript interface to interact with web code
-Native code implementation (Java, Swift, etc.)
-Plugin metadata (plugin.xml) defining plugin structure
Steps to publish a plugin to npm:
-Create a new folder with plugin code (native + JS).
-Add a plugin.xml file to define plugin structure and capabilities.
-Create a package.json file for npm compatibility.
-Run npm login to authenticate with your npm account.
-Use npm publish to upload the plugin to the npm registry.

21) What is Intent? List its types.


An Intent is a messaging object used to request an action from another app component.
Types of Intent: Explicit Intent – Specifies the exact component to start.
Implicit Intent – Declares a general action to perform, allowing other apps to handle it.
22) Which class is used to create notification?
The class used to create notifications in Android is NotificationCompat.Builder, which is part
of the androidx.core.app package. It helps build notifications that work across various
Android versions.

23) List various types of menus in Android.


Options Menu – The primary menu for an activity, shown when the user presses the menu
button.
Context Menu – Appears when the user long-presses on a view.
Popup Menu – A small menu that shows up anchored to a specific view, often used for
overflow actions.

24) What is PhoneGap?


PhoneGap (now known as Apache Cordova) is a mobile application development framework
that allows developers to create apps using HTML, CSS, and JavaScript. It enables
cross-platform development by wrapping web applications into a native container.

25) Manifest File


The AndroidManifest.xml file is a crucial part of every Android application. It provides
essential information about the app to the Android operating system before any code is
executed. Key Functions of the Manifest File:
Declares app components – Activities, Services, Broadcast Receivers, and Content
Providers.
Defines app permissions – What permissions the app requires (e.g., Internet, Camera).
Specifies app features – Such as hardware and software requirements (camera, Bluetooth).
Declares app metadata – Such as app name, icon, version, theme, etc.
Sets application entry point – Using the <intent-filter> to specify the main activity.

26) Describe android fragment lifecycle.


A Fragment is a reusable portion of an activity that has its own lifecycle. The fragment
lifecycle is closely tied to the activity lifecycle but includes additional methods for managing
its own behavior.
onAttach()

onCreate()

onCreateView()

onViewCreated()

onActivityCreated()

onStart()

onResume()

(onPause → onStop → onDestroyView → onDestroy → onDetach)
27) What is Grid View?
A GridView is a layout in Android that displays items in a two-dimensional, scrollable grid. It
is commonly used to display images or icons in a structured grid format.

28) Explain the components of android architecture


Android architecture is a stack of software components structured in four main layers, each
serving a specific role in managing the hardware and providing services to applications.
1)Linux Kernel (Bottom Layer):
Core of Android OS. Handles hardware abstraction, memory management, process
management, device drivers, etc. Acts as a bridge between the hardware and upper layers.

2. Hardware Abstraction Layer (HAL):


Provides standard interfaces to interact with device hardware (camera, sensors, GPS, etc.).
Ensures hardware-specific implementations are separate from higher-level services.

3. Android Runtime (ART) & Core Libraries:


ART (Android Runtime): Executes bytecode for Android apps using ahead-of-time (AOT)
compilation.
Core Libraries: Provide essential APIs (like Java Collections, I/O, etc.) used by applications.

4. Native C/C++ Libraries:


Libraries like WebKit, SQLite, OpenGL, and others are written in C/C++ and accessed via
Java APIs. Offer functionalities like database access, graphics rendering, and web browsing.

5. Application Framework:
Provides higher-level services to applications.
Includes managers like: Activity Manager, Window Manager, Content Providers, Location
Manager, Notification Manager

6. Applications (Top Layer):


The final layer where user-installed apps and built-in apps (Phone, Contacts, Browser)
reside. Interact with the Application Framework to perform tasks.

29) Write any 4 features of Location Manager class


1)Location Updates:
It allows an app to request periodic updates of the device’s geographical location using GPS,
network, or passive providers.
2)Provider Management:
It supports multiple location providers (like GPS, Network, Passive) and lets developers
choose or switch between them based on accuracy and power consumption.
3)Proximity Alerts:
You can set proximity alerts that trigger when the device enters or exits a specified
geographical area.
4)Geocoding Support:
Works with Geocoder to convert geographic coordinates (latitude & longitude) into
human-readable addresses and vice versa.
30) Explain Android Notification with an example.
A Notification in Android is a message that appears outside your app’s UI to provide users
with timely information or reminders. Notifications are typically shown in the notification
drawer and can launch an activity or perform actions when clicked.
Key Components of a Notification:
Title & Content – Basic text shown to the user.
Icon – Small icon representing the app or type of notification.
Action – What happens when the user taps the notification (e.g., opens an activity).
Priority – Controls how urgent the notification is.

31) What is Android virtual device?


An Android Virtual Device (AVD) is an emulator configuration that allows developers to
simulate an Android device on a computer. It is used for testing and running Android
applications without needing a physical device. AVD is a powerful tool that helps Android
developers test apps efficiently on multiple device configurations.

32) What is parsing? Explain JSON parsing


Parsing is the process of converting raw data (usually in text format) into a structured format
that a program can understand and work with. In Android, parsing is commonly used to read
data from sources like web APIs, files, or databases.
JSON (JavaScript Object Notation) is a lightweight data format used for data exchange
between a server and client. In Android, JSON parsing means converting JSON data into
Java objects so the app can use it.

33) What is linear layout in android?


LinearLayout is a view group that arranges its child views either vertically or horizontally, one
after another in a single direction. .Key Attributes:
android:orientation="vertical" or "horizontal" — sets the direction of layout.
android:layout_width and android:layout_height — define size.
android:gravity — controls alignment.
android:layout_weight — distributes space among children.

34) List any five factors in developing mobile application


1)User Interface (UI) & User Experience (UX):
A clean, intuitive, and responsive design improves user engagement and satisfaction.
2)Performance & Speed:
The app should load quickly and run smoothly to retain users.
3)Device Compatibility:
Ensure the app works across different screen sizes, resolutions, and Android versions.
4)Security:
Protect user data using proper authentication, encryption, and secure APIs.
5)Battery & Resource Optimization:
Efficient use of memory, CPU, and network helps avoid draining the device battery.

35) What is Dalvik Virtual machine


The Dalvik Virtual Machine is a specialized virtual machine used by older versions of the
Android operating system to run apps written in Java. It was designed specifically for mobile
devices with limited memory and processing power.
36) Explain JSON Parsing Method of json object.
1.get(String name): This method is used to get the value from JSONObject. It returns the
value of object type. Pass the String type key and it returns the value of Object type if exists
otherwise it throws JSONException.
2.getBoolean(String name): This method is used to get the Boolean value from JSONObject.
Pass the String type key and it returns the value of Boolean type if exists otherwise it throws
JSONException.
3.getDouble(String name): This method is used to get the double type value from
JSONObject. Pass the String type key and it returns the value in double type if exists
otherwise it throws JSONException.
4. getInt(String name): This method is used to get the int type value from JSONObject. Pass
the string type key and it returns the value in int type if exists otherwise it throws
JSONException.
5.getJSONArray(String name): This method is used to get the JSONArray type value. Pass
the String type key and it returns JSONArray if exists otherwise it throws JSONException.
6.getJSONObject(String name): This method is used to get the JSONObject type value.
Pass the String type key and it returns the JSONObject value if exists otherwise it throws
JSONException.
7. getLong(String name): This method is used to get the long type value from JSONObject.
Pass the String type key and it returns the value in long type if exists otherwise it throws
JSONException.

37) Explain parsing method of JSONArray.


1.get(int index): This method is used to get the value from JSONArray. It returns the value of
object type. Pass the index and it returns the value of object type if exists otherwise itthrows
JSONException.
2.getBoolean(int index): This method is used to get the Boolean value from JSONArray.
Pass the index and it returns the value of Boolean type if exists otherwise it throws
JSONException.
3.getDouble(int index): This method is used to get the double type value from JSONArray.
Pass the index and it returns the 'value in double type if exists otherwise it throws
JSONException. getInt(int index): This method is used to get the int type value from
JSONArray. Pass the index and it returns the value in int type if exists otherwise it throws
JSONException.
4.getJSONArray(int index): This method is used to get the JSONArray type value. Pass he
index and it returns JSONArray if exists otherwise it throws JSONException.
5.getJSONObject(int index): This method is used to get the JSONObject type value. Pass
the index and it returns the JSONObject value if exists otherwise it throws JSONException.
6.getLong(int index): This method is used to get the long type value from JSONArray. Pass
the index and it returns the value in long type if exists otherwise it throws JSONException

You might also like