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

Android Basics

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

Android Basics

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

Android Basics

1. What is Android and what are components of Android applications?


* Android: Android is an open-source, Linux-based operating system designed primarily for mobile
devices such as smartphones and tablets. It's developed by the Open Handset Alliance, led by
Google.
* Components of Android Applications:
* Activities: An Activity represents a single, focused thing that the user can do. It's usually a
single screen with a user interface.
* Services: A Service is a component that runs in the background to perform long-running
operations or to perform work for remote processes. It doesn't have a user interface.
* Broadcast Receivers: A Broadcast Receiver is a component that responds to system-wide
broadcast announcements. Many broadcasts originate from the system-for example, a broadcast
announcing that the screen has turned off, the battery is low, or a picture was captured.
* Content Providers: A Content Provider manages a shared set of app data that you can store in
the file system, in an SQLite database, or on the web. Through the content provider, other apps can
query or even modify the data (if the content provider allows it).
* Intents: Intents are messaging objects that you can use to request an action from another app
component. Although they facilitate communication between activities, they can also be used to
send broadcasts, start services, and more.
* Fragments: A Fragment represents a portion of a user interface in an Activity. You can combine
multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple
activities.
* Views and View Groups: Views are UI elements like buttons, text fields, and images. View
groups are containers for views, like layouts.
* Resources: Resources are external assets that your app uses, such as images, strings, and
layout definitions.

2. Briefly explain Intents.


* Intents: Intents are messaging objects that Android components use to communicate with each
other. They are like asynchronous messages that allow you to request an action from another
application component.
* Explicit Intents: Specify the exact component that should receive the intent. Used when you
know the class name of the target component.
* Implicit Intents: Declare a general action to perform, allowing other apps to handle it. The
system determines which component can handle the intent based on intent filters.
* Intents can carry data called extras.

3. What are activity lifecycle callbacks?


* Activity Lifecycle Callbacks: Activities in Android have a lifecycle, which is a set of states they go
through as the user interacts with them. The Android system provides callback methods that are
invoked when an activity transitions between these states.
* onCreate(): Called when the activity is first created.
* onStart(): Called when the activity becomes visible to the user.
* onResume(): Called when the activity starts interacting with the user.
* onPause(): Called when the system is about to resume another activity.
* onStop(): Called when the activity is no longer visible to the user.
* onRestart(): Called after the activity has been stopped, prior to it being started again.
* onDestroy(): Called before the activity is destroyed.

4. How Bound services work and explain three types of services.


* Bound Services: A bound service allows components (such as activities) to bind to it and interact
with it. A bound service provides a client-server interface, allowing components to send requests to
the service and receive results.
* Types of services:
* Foreground Services: These services perform operations that are noticeable to the user. They
must display a notification to indicate that they are running. Examples include playing music or
downloading a file.
* Background Services: These services perform operations that are not directly noticeable to the
user. They are used for tasks that don't require user interaction, such as syncing data. Background
services have more restrictions in newer android versions.
* Bound Services: As explained above, bound services provide a client-server interface for
components to interact with them.

5. What are Broadcast Receivers? Give some examples.


* Broadcast Receivers: Broadcast Receivers are components that listen for system-wide
broadcast announcements. They allow your application to react to events that occur outside of your
application's normal flow.
* Examples:
* Receiving a notification when the device's battery level is low.
* Detecting when the device's network connectivity changes.
* Responding to incoming SMS messages.
* Knowing when the device has finished booting.
* Detecting when a picture has been taken.
6. Explain Android Manifest File.
* Android Manifest File (AndroidManifest.xml): The manifest file is an essential part of every
Android application. It provides crucial information about your app to the Android system.
* It declares the application's components (activities, services, broadcast receivers, and content
providers).
* It specifies the permissions that the application requires.
* It defines the minimum API level that the application supports.
* It declares the application's hardware and software requirements.
* It contains meta data about the application.
* It declares intent filters, that determine which intents an application component can respond to.

You might also like