Android Question – 2

  1. What is Android Debug Bridge(ADB)?
    Android Debug Bridge is a command-line tool used to allow and control communication with an emulator instance. It gives the power for developers to execute remote shell commands to run applications on an emulator.
  2. What is DDMS?
    DDMS(Dalvik Debug Monitor Server) is a debugging tool in the Android platform. It gives the following list of debugging features:

Port forwarding services.
Thread and heap information.
Logcat.
Screen capture on the device.
Network traffic tracking.
Incoming call and SMS spoofing.
Location data spoofing.

  1. What is AIDL? Which data types are supported by AIDL?
    AIDL(Android Interface Definition Language) is a tool that handles the interface requirements between a client and a service for interprocess communication(IPC) to communicate at the same level.

The process involves dividing an object into primitives that are understood by the Android operating system. Data Types supported by AIDL is as follows:

String
List
Map
CharSequence
Java data types (int, long, char, and boolean)

  1. What is the life cycle of Android activity?
    OnCreate(): It is called when activity is created. Using this, the views are created and data is collected from bundles.
    OnStart(): It is called if the activity is becoming visible to the user. It may be succeeded by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
    OnResume(): It is called when the activity will start an interaction with the user.
    OnPause(): This is called when the activity is moving to the background but hasn’t been killed yet.
    OnStop(): This is called when an activity is no longer visible to the user.
    OnDestroy(): This is called when the activity is finished or destroyed.
    OnRestart(): This is called after the activity has been stopped, prior to it being started again.
  2. Explain Sensors in Android.
    Android-based devices have a collection of built-in sensors in them, which measure certain parameters like motion, orientation, and many more through their high accuracy. The sensors can be both hardware and software based on nature. There are three prominent categories of sensors in Android devices. They are:

Position Sensor: It is used for measuring the physical position of the Android device. This has orientation sensors and magnetometers.
Motion Sensors: These sensors consist of gravity, rotational activity, and acceleration sensors which measure the rotation of the device or the acceleration, etc.
Environmental Sensor: It includes sensors that measure temperature, humidity, pressure, and other environmental factors.

  1. Explain the dialog boxes supported on Android.
    Android supports four dialog boxes. They are:

AlertDialog:
The AlertDialog supports 0-3 buttons, along with a list of selectable items such as checkboxes and radio buttons.
It is used when you want to ask the user about taking a decision between yes or no in response to any particular action taken by the user, by remaining in the same activity and without changing the screen.
DatePickerDialog:
It is used for selecting the date by the user.
TimePickerDialog:
Used for selecting the time by the user.
ProgressDialog:
It is an extension of the AlertDialog and is used to display a progress bar. It also supports the addition of buttons.
This class was deprecated in API level 26 because it prevents the user from interacting with the application. Instead of this class, we can use a progress indicator such as ProgressBar, which can be embedded in the user interface of your application.

  1. What is AndroidManifest.xml file and why do you need this?
    The AndroidManifest.xml file contains information regarding the application that the Android system must know before the codes can be executed.
    This file is essential in every Android application.
    It is declared in the root directory.
    This file performs several tasks such as:
    Providing a unique name to the java package.
    Describing various components of the application such as activity, services, and many more.
    Defining the classes which will implement these components.
  2. What is an intent?
    An intent is a messaging object that is used to request an action from other components of an application. It can also be used to launch an activity, send SMS, send an email, display a web page, etc.

It shows notification messages to the user from within an Android-enabled device. It alerts the user of a particular state that occurred. There are two types of intents in Android:

Implicit Intent- Used to invoke the system components.
Explicit Intent- Used to invoke the activity class.

  1. Mention the difference between class, file and activity in Android?
    The difference between them is as follows:

Class is a compiled form of a .java file that Android uses to produce an executable .apk file.
A file is a block of arbitrary information or resources used for storing information. It can be of any file type.
Activity is a single screen that represents GUI(Graphical User Interface) with which users can interact in order to do something like dial the phone, view email, etc.

  1. What is a Toast? Write its syntax.
    Toast is a message that pops up on the screen. It is used to display the message regarding the status of the operation initiated by the user and covers only the expanse of space required for the message while the user’s recent activity remains visible and interactive.

Toast notification automatically fades in and out and it does not accept interaction events.

  1. What is context?
    The context in Android is the context of the current state of the application or object. The context comes with services like giving access to databases and preferences, resolving resources, and more.

There are two types of context. They are:

Activity context

This activity context is attached to the lifecycle of an activity.
The activity context can be used when you are passing the context in the scope of an activity or you need the context whose lifecycle is attached to the context of the activity.
Application context:

This application context is attached to the lifecycle of an application.
The application context should be used where you need a context whose lifecycle is separate from the current context or when you are passing a context beyond the scope of activity.

Leave a Reply0