Q1. What is the latest version of Android? List all the versions of Android.
The most recent version, Android 13, was published on August 15, 2022, while the recently
released Android 12.1/12L offers advancements for foldable phones, tablets, desktop-sized
screens, and Chromebooks. Android is a mobile operating system developed by Google. It is
based on the Linux kernel and designed primarily for touchscreen mobile devices such as
smartphones and tablets. Every other Android version has been named after either sweet or
desserts. The following table represents the Android name, version and the year of release.
Android Name Version Year of Release
Android 1.5 Android Cupcake 2009
1.6 Donut 2009
2.0-2.1 Eclair 2009
2.2 – 2.2.3 Froyo 2010
2.3 – 2.3.7 Gingerbread 2010
3.0 – 3.2.6 Honeycomb 2011
4.0 – 4.0.4 Ice Cream Sandwich 2011
4.1 – 4.3.1 Jelly Bean 2012
4.4 – 4.4.4 KitKat 2013
5.0 – 5.1.1 Lollipop 2014
6.0 – 6.0.1 Marshmallow 2015
7.0 – 7.1.2 Nougat 2016
8.0 – 8.1 Oreo 2017
9.0 Pie 2018
Q2. What is an Activity? Which method is implemented by all subclasses of an Activity?
An Activity is the screen representation of an application in Android.
It serves as an entry point for the user’s interaction. Each activity has a layout file where you can
place your UI. An application can have different activities. For example, facebook start page
where you enter your email/phone and password to login acts as an activity.
Below are the two methods which almost all subclasses of Activity will implement:
onCreate(Bundle): It is a method where your initialization is done. Under this, you will
callsetContentView(int) with a layout resource which defines your UI. Also, you can
retrieve the widgets in that UI by using findViewById(Int). These are required to interact
programmatically.
onPause(): It is a method which deals with the user whenever it leaves the activity. So
any changes made by the user should be commited which is done by
the ContentProvider that holds the data.
An activity is implemented as a subclass of Activity class as follows:
public class MainActivity extends Activity {
}
Q3. What are the features of Android?
Google has changed the lives of everyone by launching a product that improves the mobile
experience for everyone. Android helps in understanding your tastes and needs, by giving
various features such as having wallpapers, themes, and launchers which completely change the
look of your device’s interface.
Android has plenty of features. Some of the features are listed below:
Open-source
Customizable operating System
Variety of apps can be developed.
Reduces overall complexity
Supports messaging services, web browser, storage(SQLite), connectivity,media and
many more.
Q4. Explain Android Architecture.
Android architecture refers to the different layers in the Android stack. It includes your operating
system, middleware, and important applications. Each layer in the architecture provides different
services to the layer just above it. The four layers in the Android stack are:
Linux Kernel
Libraries
Android Framework
Android Applications
For more information about Android layers,
Q5. What is APK format?
The APK file or Android application package is the compressed file format that is used to
distribute and install application software and middleware onto Google’s Android operating
system. The file has .apk extension and has all the application code, resource files, certificates,
and other files, compressed in it.
Q6. What is the life cycle of android activity?
User navigates between different screen or app, it goes through different states in their lifecycle.
So an activity lifecycle consists of 7 different methods of android.app.Activity class i.e :
onCreate() : In this state, the activity is created.
onStart(): This callback method is called when the activity becomes visible to the user.
onResume(): The activity is in the foreground and the user can interact with it.
onPause(): Activity is partially obscured by another activity. Other activity that’s in the
foreground is semi-transparent.
onStop(): The activity is completely hidden and not visible to the user.
onDestroy(): Activity is destroyed and removed from the memory.
Q7. Define intents in Android. What are the different types of intents?
An Intent is an “intention” to do an action. An intent is a messaging object you can use to
request an action from another app component.
Methods are used to deliver intents to different components:
context.startActivity() – To start an activity
context.startService() – To start a service
context.sendBroadcast() – To deliver a broadcast
Types of Intent:
Implicit Intent: Implicit intent is when the target component is not defined in the intent and the
android system has to evaluate the registered components based on the intent data.
Explicit Intent: Explicit intent is when an application defines the target component directly in
the intent.
Q8. What is the difference between an implicit intent and explicit intent?
Implicit Intent is used whenever you are performing an action. For example, send email, SMS,
dial number or you can use a Uri to specify the data type. For example:
Intent i = new Intent(ACTION_VIEW,Uri.parse("<a
href="http://www.edureka.co">http://www.edureka.co</a>"));
startActivity(i);
Explicit, on the other hand, helps you to switch from one activity to another activity(often
known as the target activity). It is also used to pass data using putExtra method and retrieved by
other activity by getIntent().getExtras() methods.
Intent i = new Intent(this, Activitytwo.class); #ActivityTwo is the target component
i.putExtra("Value1","This is ActivityTwo");
i.putExtra("Value2","This Value two for ActivityTwo");
startactivity(i);
Q9. What is an Android Framework?
Android Framework is an essential part of the Android Architecture. It is a set of APIs that
allows developers to write apps and has the following components:
Components that conduct long-running operations in the background, without the
Services
inclusion of a user interface.
Objects that initiate actions from other app components, either within your program
Intent
(explicit intents) or through another piece of software on the device (implicit intents).
Components that provide users with screens on which they can interact with objects and
Activities
perform actions. This is the base from which Intents can be deployed.
Components that enable users to access data within an app such as audio, video, images,
Content Providers
contact information, etc.
Others App widgets and Processes and Threads
Q10. What is the difference between File, Class, and Activity in android?
The difference between them are as follows:
File is a block of arbitrary information or resources for storing information. It can be any
file type.
Class is a compiled from of .Java file which Android uses to produce an executable apk.
Activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type
but just a class that can be extended in Android to load UI elements on view.
Q11. What is Google Android SDK? What are the tools placed in android SDK?
The Google Android SDK is a toolset that provides a developer the API libraries and tools
required to build, test, and debug apps for Android in Windows, Mac or Linux. The tools placed
in Android SDk are:
Android Emulator
DDMS – Dalvik Debug Monitoring Services
AAPT – Android Asset Packaging tool
ADB – Android debug bridge
Q12. What is a Toast? Write its syntax.
Toast notification is a message that pops up on the window.
It only covers the expanse of space required for the message and the user’s recent activity
remains visible and interactive.
The notification automatically fades in and out and does not accept interaction events.
Toast.makeText(ProjectActivity.this, "Your message here", Toast.LENGTH_LONG).show();
Q13. What is an Android Framework?
Android Framework is an essential part of the Android Architecture. It is a set of APIs that
allows developers to write apps and has the following components:
Q14. What is an ANR? What are some measures you can take to avoid ANR?
ANR stands for ‘Application Not Responding’. This dialogue is displayed if the main thread in
the application has been unresponsive for a long time and in the following conditions:
When there is no response to an input event after 5 seconds.
When a broadcast receiver is not done executing within 10 seconds.
Following measures can be taken to avoid ANR:
To avoid ANR, an app should perform a lengthy database or networking operations in
separate threads.
One technique is to create a child thread to prevent the Android system from concluding
a code that has been unresponsive for a long period of time. Most of the actual workings
of the codes can be placed within the child thread to ensure that the main thread runs with
minimal unresponsive time.
For background task-intensive apps, you can alleviate pressure from the UI thread by
using the IntentService.
Q15. What is AAPT?
AAPT is short for Android Asset Packaging Tool. This tool provides developers with the ability
to deal with zip-compatible archives, which includes creating, extracting as well as viewing its
contents.
Q16. What are broadcast receivers? How is it implemented?
Broadcast Receiver is a mechanism using which host application can listen for System
level events.
Broadcast receiver is used by the application whenever they need to perform the
execution based on system events. Like listening for Incoming call, sms etc.
Broadcast receivers helps in responding to broadcast messages from other application or
from the system.
It is used to handle communication between Android operating system and applications.
It is implemented as a subclass of BroadcastReceiver class and each message is
broadcaster as an Intent object.
public class MyReceiver extends BroadcastReceiver {
Public void onReceive(context,intent){}
}
Q17. What is the use of WebView in Android?
WebView is a view that display web pages inside your application. According to Android, “this
class is the basis upon which you can roll your own web browser or simply display some online
content within your Activity. It uses the WebKit rendering engine to display web pages and
includes methods to navigate forward and backward through a history, zoom in and out, perform
text searches and more. In order to add WebView to your application, you have to
add <WebView>element to your XML layout file.
Q18. What are the different kinds of context in Android?
Context defines the current state of an App. Context provides access to creating new activity
instance, access databases, start a service, etc. There is a base class ApplicationContext, and
subclasses for components: Activity, Service.
Q19. What is a Service? How is it implemented?
A service in android is a background process which is used to perform long-running operations.
Let’s say, a service of location is active in the background while the user is in a different
application. So it does not disturb the user interaction with an activity. Now, services are
classified into two types, namely:
1. Local: This service is accessed from within the application.
2. Remote – This service is accessed remotely from other applications running on the same
device.
It is implemented as a subclass of Service class as follows :
public class MyService extends Service {
}
Q20. How does Manifest file plays an integral role in App development?
Manifest file plays an integral role as it provides the essential information about your app to the
Android system, which the system must have before it can run any of the app’s code. Manifest
file performs various tasks such as:
It names the Java package for the app as the package name serves as a unique identifier
for the application.
It protects the application by declaring permissions in order to access protected parts of
the API and interact with other applications.
Manifest file declares the minimum level of the android API and list the libraries which is
linked with the application.
Manifest file list the instrumentation classes. These classes provide profiling and other
information as the application runs, but this information is removed as soon the
application is publishes. It remains only till the application is in development mode.
Structure of a manifest file: The structure of a manifest file consists of various elements such
as action, activity, activity-alias and many more. Refer to the below screenshot which shows the
general structure of the manifest file.
Q21. What is the difference between a fragment and an activity?
Activity is typically a single, focused operation that a user can perform such as dial a number,
take a picture, send an email, view a map etc.
Fragment is a modular section of an activity, with its own lifecycle and input events, and which
can be added or removed at will. Also, a fragment’s lifecycle is directly affected by its host
activity’s lifecycle i.e. when the activity is paused, so are all fragments in it, and when the
activity is destroyed, so are all of its fragments.
Q22. What is DDMS?
DDMS stands for Dalvik Debug Monitor Server. It gives the following array of debugging
features:
Port forwarding services
Screen capture on the device
Thread and heap information
Logcat
Incoming call and SMS spoofing
Network traffic tracking
Location data spoofing
Q23. What is the difference between Service and Thread?
Service Thread
Service is like an Activity but has no interface. A Thread is a concurrent unit of execution.
A Service is not a separate process. It works in By default, all components of the same
background until the service or someone else application run in the same process and
explicitly stop it. thread (called the “main” thread).
Thread is killed when an Application is
Service is not killed when an application is killed.
killed.
It expose some of its functionality to other GOOGLE has brought in Handlers and
applications by calling Context.bindService(). loopers into android threads.
Q24. What is an Android Runtime?
Android Runtime consists of Dalvik Virtual machine and Core Java libraries.
DVM is optimized for low processing power and low memory environments.
Unlike JVM, the Dalvik Virtual Machine doesn’t run .class files, instead it runs .dex files.
Android 2.2 “Froyo“ brought trace-based just-in-time (JIT) compilation into Dalvik,
optimizing the execution of applications and dynamically compiling frequently executed
short segments of their bytecode into native machine code.
Q25. What is a content provider? How is it implemented?
Content providers manage access to a structured set of data. It is the standard interface
that connects data in one process with code running in another process.
They encapsulate the data and provide mechanisms for defining data security.
Content providers are used to share the data between different applications.
It is implemented as a subclass of ContentProviderclass and must implement a standard set of
APIs that enable other applications to perform transactions.
public class MyContentprovider extends ContentProvider {
public void onCreate(){}
}
Q26. Can you list and explain the four Java classes related to using sensors on the Android
platform?
Sensor Manager: This class provides methods regarding the registration of sensor event
listeners, the management of data acquisition, and calibration. It also provides methods for
accessing and listing sensors.
Sensor: This class creates an instance of a specific sensor, providing methods that allow you to
determine its capabilities.
SensorEvent: This class provides information on a sensor event by creating a sensor event
object.
SensorEventListener: This interface provides two callback methods that can receive
notifications of sensor events.
Q27. What is Orientation in android? How is it done?
Orientation helps to represent the layout in a row or column.
Syntax:
<activity android name=".activity" android: screenOrientation="portrait">
Q28. What is a layout in Android?
A layout is a resource file that defines the visual structure for a user interface in an Android app.
You can use layouts to define screen layouts, individual controls, and even small groups of
controls.
Q29. Can you explain the difference between an android:id and android:tag attribute?
The id attribute is used to uniquely identify a view within the layout. The tag attribute is used to
store a custom string that can be used to identify a view.
Q30. Why are layouts important when developing an app on Android?
Layouts are important in Android development because they provide a way to organize and
structure your app’s UI. Without a layout, your app would simply be a collection of unorganized
views. By using a layout, you can more easily control how your views are positioned and
displayed on screen. This can help make your app more user-friendly and easy to navigate.
Q31. How do you align views within a layout in Android?
There are a few different ways to align views within a layout in Android. The most common way
is to use a LinearLayout, which arranges views in a single row or column. You can also use a
RelativeLayout, which allows you to position views relative to each other or to the parent layout.
Finally, you can use a ConstraintLayout, which allows you to specify constraints for views in
order to position them relative to each other.
Q32. What’s the best way to force all children of a LinearLayout to have the same width?
By setting the android:layout_width attribute to “0dp” and the android:layout_weight attribute to
“1” for each child.
Q33. What are some ways to center multiple widgets within a layout in Android?
There are a few ways to center multiple widgets within a layout in Android. One way is to use a
RelativeLayout and set the android:layout_centerInParent attribute to true for each widget that
you want to center. Another way is to use a LinearLayout with the android:gravity attribute set to
center.
Q34. What is FrameLayout used for in Android?
FrameLayout is a layout manager that allows you to place child views within it in a specific
position. You can think of it as a blank canvas where you can add views in whatever position
you want.
Q35. What’s the purpose of using a RelativeLayout in Android?
RelativeLayout is a layout that allows you to specify the position of child elements in relation to
other elements on the screen. This can be useful for creating complex layouts where elements
need to be positioned in relation to each other.
Q36. What are some common attributes used with layouts in Android?
Some common attributes used with layouts in Android are layout_width, layout_height, and
gravity. These attributes help to control the size and position of elements within a layout.
Q37. When would you use a TableLayout instead of a GridLayout or RelativeLayout?
TableLayout is used to arrange the content in a table format. GridLayout is used to arrange the
content in a grid format. RelativeLayout is used to arrange the content in a relative format.
Q38. What does the match_parent property mean when setting the height or width of a
view in Android?
The match_parent property means that the view will take up as much space as is available in the
parent view. This is different from the wrap_content property, which means that the view will
only take up as much space as is necessary to display its contents.
Q39. What happens if you set the android:layout_height as wrap_content and the
android:layout_width properties as match_parent for a TextView widget?
The TextView widget will expand to fill the entire width of its parent container, but its height
will only be as large as is necessary to fit the text it contains.
Q40. What are different types of layouts available in Android?
There are four different types of layouts available in Android: LinearLayout, RelativeLayout,
GridLayout, and FrameLayout. Each type of layout has its own set of advantages and
disadvantages, so it is important to choose the right one for your needs. LinearLayout is the
simplest type of layout, and is great for creating simple, straightforward layouts. RelativeLayout
is more flexible than LinearLayout, and allows you to position views in relation to other views or
the parent layout. GridLayout is perfect for creating grid-based layouts, and is especially useful
for creating layouts with multiple columns. Finally, FrameLayout is a very basic layout that
simply places views on top of each other, one on top of the other.
Q41. Is it possible to define a Layout at runtime in Android? If yes, then how?
Yes, it is possible to define a Layout at runtime in Android. This can be done using the
LayoutInflater class. The LayoutInflater class is used to instantiate layout XML files into their
corresponding View objects. It can also be used to inflate complex View hierarchies from XML
into the current ViewGroup.
Q42. What is the significance of padding and margin in Android?
Padding and margin in Android help to create space between the various elements on a screen.
Padding is the space within an element, while margin is the space outside of an element. Padding
and margin can be used to create visual balance and hierarchy on a screen, and can also be used
to help with spacing issues.
Q43. What are the effects of setting the android:windowSoftInputMode property to
adjustPan?
When set to adjustPan, the activity’s main window is not resized to make room for the soft
keyboard. Rather, the content of the window is panned so that the current focus is never obscured
by the keyboard and users can always see what they are typing. This is generally less disruptive
than resizing the window, but may not be suitable for all applications.
Q44. What do you understand by “gravity” in Android?
Gravity is a parameter used in Android to define how a view is positioned within its parent view.
By default, gravity is set to “left” which means that the view will be positioned to the left of its
parent view. However, you can also set gravity to “right”, “center”, “top”, or “bottom” to
position the view accordingly.
Q45. What’s the difference between fill_parent and match_parent properties in Android?
The fill_parent property is used to make a view as wide as its parent, while the match_parent
property is used to make a view as wide as its parent, including any margins.
Q46. What would happen if you set the orientation of a VerticalLinearLayout as
horizontal?
If you set the orientation of a VerticalLinearLayout as horizontal, then the layout would become
a HorizontalLinearLayout. This would cause all of the child views to be arranged horizontally,
from left to right.
Q47. What’s the effect of setting clipChildren=false on a ViewGroup?
By default, Android will clip (or “cut off”) any children of a ViewGroup that extend beyond the
bounds of the ViewGroup. Setting clipChildren=false on a ViewGroup will disable this behavior,
meaning that any children of the ViewGroup will be drawn even if they extend beyond the
bounds of the ViewGroup. This can be useful for certain types of animations or effects.
Q48. Describe any four android UI elements with code
TextView: A TextView is used to display text on the screen.
<TextView
android:id="@+id/myTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, World!"
android:textSize="18sp"
android:textColor="#000000"
/>
Button: A Button is used to trigger an action when clicked.
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
/>
EditText: An EditText is used to take user input.
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your text"
android:inputType="text"
/>
ImageView: An ImageView is used to display images.
<ImageView
android:id="@+id/myImageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/my_image"
android:scaleType="centerCrop"
/>
These are basic examples, and you can customize these elements further by adjusting attributes
such as layout parameters, text properties, and appearance. Make sure to replace the
placeholder values (like @+id/myTextView or @drawable/my_image) with actual resource
references from your project.
Q49. html 5 for mobiles
HTML5 is a versatile markup language that is commonly used for creating content on the web,
including mobile websites. When developing mobile-friendly web pages, you can use HTML5
along with CSS and JavaScript to create responsive and interactive designs. Here's a basic
template for an HTML5 document that you might use as a starting point for a mobile website:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Mobile Website</title>
<style>
/* Add your CSS styles here for mobile responsiveness */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
header {
background-color: #333;
color: #fff;
text-align: center;
padding: 10px;
}
main {
padding: 20px;
}
/* Add more styles as needed */
</style>
</head>
<body>
<header>
<h1>Your Mobile Website</h1>
</header>
<main>
<p>Welcome to your mobile website! This is a sample content area.</p>
<!-- Add your content here -->
</main>
<footer>
<p>© 2024 Your Company</p>
</footer>
</body>
</html>
This template includes a basic structure with a header, main content area, and a footer.
It also includes a viewport meta tag to ensure proper scaling on mobile devices. You can
customize the styles within the <style> tag to fit the design of your mobile website.
Additionally, you might want to consider using responsive design techniques, such as
media queries in your CSS, to adapt the layout for different screen sizes. JavaScript can
be added as needed for interactive elements or additional functionality.
Q.50 what is android stack
The term "Android stack" can refer to different concepts within the context of Android
development. Here are two common interpretations:
Software Stack:
In Android development, the "Android stack" can refer to the software stack, which is the
combination of software components and layers that make up the Android operating system. The
Android software stack includes:
Linux Kernel: The core of the operating system, handling low-level hardware interactions.
Libraries: Software libraries for functions such as graphics rendering, data storage, and more.
Android Runtime (ART/Dalvik): The runtime environment responsible for running Android
apps.
Application Framework: A set of APIs and tools that developers use to create applications.
Applications: The top layer where user-installed applications reside.
Development Stack:
The "Android stack" can also be used to describe the technology stack or development stack used
to build Android applications. In this context, it includes the tools, languages, and frameworks
used by developers:
Java or Kotlin: Primary programming languages for Android development.
Android Studio: The official integrated development environment (IDE) for Android app
development.
Android SDK (Software Development Kit): A set of tools and libraries necessary for
developing Android applications.
Gradle: A build automation system used to compile and build Android projects.
XML: Markup language used for defining the layout and structure of Android user interfaces.
Understanding the Android stack in either context is crucial for developers to build efficient and
effective Android applications.