Android Interview Questions — Freshers(0–2 years Experience)

Deepak Kaligotla
27 min readSep 6, 2023

--

1. List the languages used to build Android

The most popular programming languages that can be used to develop applications in Android are:

Java:
It has always been a starting point for new developers and used by the majority of people who work with Android development. Eclipse, NetBeans, and IntelliJ IDE are the most popular IDE’s(Integrated Development Environment) used for developing an Android application using java.

Kotlin:
Kotlin is a relatively new, modern, safe, and object-oriented cross-platform programming language used in developing an Android application. IDE’s used with kotlin are Android studio, Eclipse IDE, etc.

C#:
Developers can build native iOS and Android mobile applications by using the C# language. Visual Studio is the best tool for developing an Android application using C#.

Python:
It is a dynamic and object-oriented programming language. It is very popular in machine learning. Pydroid 3, Dcoder, spck code editor is some of the code editors for Python.

Other languages which can be used in Android development are C++, HTML 5. C4droid, CppDroid, AIDE, etc. are IDE’s for C++. Acode, spck code editor, etc. are examples of IDE’s used with HTML.

4. Differentiate Activities from Services.

Activities can be terminated or closed anytime the user wishes. On the other hand, services are designed to run in the background, and they can act independently.

Most of the services run continuously, irrespective of whether there are certain or no activities being executed.

Activities:
They are designed to run in the foreground.
Used when the user interface is necessary.
They are dependent.

Services:
These are mainly designed to run in the background. Foreground services are also available.
Used when the user interface is not necessary.
They act independently.

5. What is Google Android SDK? Which are the tools placed in Android SDK?

The Google Android SDK is a toolset used by developers to write applications on Android-enabled devices.

The tools placed in Android SDK are given below:

1. Android Emulator — Android Emulator is a software application that simulates Android devices on your computer so that you can test the application on a variety of devices and Android API levels without having each physical device.

2. DDMS(Dalvik Debug Monitoring Services) — It is a debugging tool from the Android software development kit (SDK) which provides services like message formation, call spoofing, capturing screenshots, etc.

3. ADB(Android Debug Bridge) — It is a command-line tool used to allow and control communication with the emulator instance.

4. AAPT(Android Asset Packaging Tool) — It is a build tool that gives the ability to developers to view, create, and update ZIP-compatible archives (zip, jar, and apk).

6. What is the use of Bundle in Android?

Bundles are used to pass the required data between various Android activities. These are like HashMap that can take trivial data types. Below code shows how to transfer a piece of data by using bundle:

Bundle b=new Bundle();
b.putString("Email","abc@xyz.com");
i.putExtras(b); // where i is intent

7. What is an Adapter in Android?

An adapter in Android acts as a bridge between an AdapterView and the underlying data for that view. The adapter holds the data and sends the data to the adapter view, the view can take the data from the adapter view and shows the data on different views like a spinner, list view, grid view, etc.

8. What is AAPT?

AAPT stands for Android Asset Packaging Tool. It is a build tool that gives the ability to developers to view, create, and update ZIP-compatible archives (zip, jar, and apk). It parses, indexes, and compiles the resources into a binary format that is optimized for the platform of Android.

9. What is portable Wi-Fi hotspot?

Portable Wi-Fi Hotspot permits you to share your mobile internet connection with other wireless devices. For example, using your Android phone as a Wi-Fi hotspot, you can use your laptop to connect to the internet using that access point.

10. 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.

11. 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.

12. 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)

14. 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:

1. Position Sensor: It is used for measuring the physical position of the Android device. This has orientation sensors and magnetometers.

2. Motion Sensors: These sensors consist of gravity, rotational activity, and acceleration sensors which measure the rotation of the device or the acceleration, etc.

3. Environmental Sensor: It includes sensors that measure temperature, humidity, pressure, and other environmental factors.

15. Explain the dialog boxes supported on Android.

Android supports four dialog boxes. They are:

1. 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.

2. DatePickerDialog:
It is used for selecting the date by the user.

3. TimePickerDialog:
Used for selecting the time by the user.

4. 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.

16. 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.

17. 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.
Intent i = new Intent(ACTION_VIEW,Uri.parse("http://www.interview bit.com")); 
startActivity(i);
  • Explicit Intent- Used to invoke the activity class.
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);

18. 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.

19. 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

Toast.makeText(ProjectActivity.this, "Your message here", Toast.LENGTH_LONG).show();

20. 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:

1. 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.

2. 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.

21. What is ANR in Android? What are the measures you can take to avoid ANR?

ANR(Application is Not Responding) is a dialog box that appears when the application is not responding. This ANR dialogue is displayed whenever the main thread within an application has been unresponsive for a long time under the following conditions:

When there is no response to an input event even after 5 seconds.
When a broadcast receiver has not completed its execution within 10 seconds.

Following measures can be taken to avoid ANR:
An application should perform lengthy database or networking operations in separate threads to avoid ANR.
For background task-intensive applications, you can lessen pressure from the UI thread by using the IntentService.

22. What are the troubleshooting techniques you can follow if an application is crashing frequently?

If an Android application is crashing frequently, you can follow the below-given techniques:

Compatibility Check:

It is not possible to test an application for all kinds of devices and operating systems. There might be a possibility that an application is not compatible with your OS.

Memory Management:

  • Some apps run perfectly on one mobile device but might crash on other devices. This is where processing power, memory management, and CPU speed are considered.
  • As there is a limited amount of memory space on mobile devices, you can free up memory space for the application to function properly.
  • If an application is frequently crashing, you can delete the application’s data, which will clear its cache memory and allow some free space on your device and might boost the app’s performance.

23. Explain different launch modes in Android.

The different launch modes in Android are given below:

Standard:

  • This launch mode generates an activity’s new instance in the task from which it originated.
  • It is possible to create several instances for the same activity.
  • For Example, suppose our current stack is A -> B -> C. Now, if we launch activity B again with the “standard” launch mode, then the new stack will be A -> B -> C -> B.

SingleTop:

  • This launch mode is similar to the Standard launch mode except if there exists an activity’s previous instance on the top of the stack, then a new instance will not be created.
  • But the intent will be sent to the activity’s existing instance.
  • For example, suppose our current stack is A -> B -> C. Now, if we launch the activity B again with “singleTop” launch mode,then the new stack will be A -> B -> C -> B.
  • Consider another example, where the current stack is A -> B -> C. Now, if we launch activity C again with the “singleTop” launch mode, then the stack will remain the same i.e., A -> B -> C. The intent will be passed to the onNewIntent() method.

SingleTask:

  • This launch mode will create a new task and push a new instance to the task as the root.
  • For example, suppose our current stack is A -> B -> C -> D. Now, if we launch activity B again with the “singleTask” launch mode, then the new stack will be A -> B. Here, a callback has been received on the old instance and C and D activities are destroyed.

SingleInstance:

  • This launch mode is similar to the SingleTask launch mode. But the system doesn’t support launching any new activities in the same task.
  • In a situation where the new activity is launched, it is launched in a separate task.
  • For example, Suppose our current stack is A -> B -> C. Now, if we launch the activity D with the “singleInstance” launch mode, then there will be two stacks: A -> B -> C -> D, If you call activity E, then it will be added to the first stack. A -> B -> C -> E -> D

Again if you Call the activity D, then it will call the same activity from the 2nd stack and pass the intent to onNewIntent().

24. What are containers?

Containers carry objects and widgets together, based on which specific items are required and in what particular arrangement is needed. Containers may hold labels, buttons, fields, or even child containers, etc. For example, if you want a form with fields on the left and labels on the right, you will need a container. If you want the OK and Cancel buttons to be below the rest of the form, next to one another, and flush to the right side of the screen, you will need a container. If you have several widgets, you will need a container to have a root element to place the widgets inside.

Android provides a collection of view classes that serve as containers for views. These container classes are called layouts, which are defined in the form of XML files that cannot be changed by our code during execution. The layout managers provided by Android SDK are LinearLayout, RelativeLayout, FrameLayout, AbsoluteLayout, GridLayout, and TableLayout.

25. What is the role of Dalvik in Android development?

Dalvik serves as a virtual machine, and it is responsible for running every Android application. Because of Dalvik, a device will have the ability to execute multiple instances of virtual machines efficiently through better memory management.

28. Explain in detail about the important file and folders used when you create a new Android application

App:

It describes the basic characteristics of the application and defines each of its components.

  1. java:

This contains the .java source files and .kt(source code written in Kotlin) source files of your project. By default, it includes a MainActivity.java or MainActivity.kt source file.

You create all the activities which have .java and .kt extensions under this file and also it includes all the code behind the application.

2. res:

It is used to store the values for the resources that are used in various Android projects to include features of color, styles, dimensions, etc.

It is a directory for files like styles.xml, strings.xml, colors.xml, dimens.xml, etc.

3. Scripts:

This is an auto-generated file that consists of compileSdkVersion, buildToolsVersion, minSdkVersion, targetSdkVersion, applicationId, versionCode, and versionName. For example, build.gradle is a script file placed in the root project directory, defines build configurations that will be applied to all modules in your project.

29. What is the difference between Serializable and Parcelable? Which is the best approach in Android?

While developing applications usually it needs to transfer data from one activity to another. This data needs to be added into a corresponding intent object. Some additional actions are required to make the data suitable for transfer. For doing that the object should be either serializable or parcelable.

Serializable:

Serializable is a standard Java interface. In this approach, you simply mark a class Serializable by implementing the interface and java will automatically serialize it.

Reflection is used during the process and many additional objects are created. This leads to plenty of garbage collection and poor performance.

Parcelable:

Parcelable is an Android-specific interface. In this approach, you implement the serialization yourself.

Reflection is not used during this process and hence no garbage is created.

Parcelable is far more efficient than Serializable since it gets around some problems with the default Java serialization scheme. Also, it is faster because it is optimized for usage on the development of Android, and shows better results.

30. What database is used in Android? How it is different from client-server database management systems?

SQLite is the open-source relational database used in Android. The SQLite engine is serverless, transactional, and also self-contained. Instead of the client-server relationship of most database management systems, the SQLite engine is integrally linked with the application. The library can be called dynamically and it can make use of simple function calls that reduce latency in database access.

31. What are the differences between Service and Thread?

The main difference between Service and Thread is given below:

32. What is the content provider? How it is implemented?

Content provider is one of the primary building blocks of Android applications, which manages access to a central repository of data. It acts as a standard interface that connects data in one process with code running in another process. So it can be used to share the data between different applications.

They are responsible for encapsulating the data and providing mechanisms for defining data security. It is implemented as a subclass of ContentProviderclass and must implement a set of APIs that will enable other applications to perform transactions.

public class MyContentprovider extends ContentProvider 
{
public void onCreate(){
}
}

33. What is the significance of the .dex file?

Android programs are compiled into a .dex file (Dalvik Executable file) by DVM, which are then zipped into a .apk file on the device. .dex files are created by translating compiled applications written in java. .dex is a format that is optimized for effective storage and memory-mappable executions.

34. What is the difference between compileSdkVersion and targetSdkVersion?

compileSdkVersion:

The compileSdkVersion is the version of API the application is compiled against. You can use Android API features involved in that version of the API (as well as all previous versions).

For example, if you try and use API 15 features but set compileSdkVersion to 14, you will get a compilation error. If you set compileSdkVersion to 15 you can still run the app on an API 14 device as long as your app’s execution paths do not attempt to invoke any APIs specific to API 15.

targetSdkVersion:

The targetSdkVersion indicates that you have tested your app on (presumably up to and including) the version you specify. This is like a certification or sign-off you are giving the Android OS as a hint to how it should handle your application in terms of OS features.

For example, setting the targetSdkVersion value to “11” or higher permits the system to apply a new default theme (Holo) to the application when running on Android 3.0 or higher. It also disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).

35. Explain about java classes related to the use of sensors on Android

Android sensor API provides many classes and interface for the use of sensors on Android. The important classes and interfaces of sensor API are given below:

1. Sensor class: This class helps you to create an instance of a specific sensor. It provides methods that let you determine a sensor’s capabilities.

2. SensorManager class: This class is used to create an instance of the sensor service. It provides methods to access and list sensors, to register and unregister sensor listeners, etc.

3. SensorEvent class: This Java class is used to create a sensor event object. It provides information about the sensor event including raw sensor data, the accuracy of data, type of sensor, timestamp of event, etc.

4. SensorEventListener interface: This interface is used to create two callback methods that receive sensor event notifications when sensor value changes or when sensor accuracy changes. Those two methods are void onAccuracyChanged(Sensor sensor, int accuracy) which is called when sensor accuracy is changed and
void onSensorChanged(SensorEvent event) which is called when sensor values are changed.

36. What is JobScheduler?

The JobSchedular API is used for scheduling different types of jobs against the framework that will be executed in your app’s own process. This allows your application to perform the given task while being considerate of the device’s battery at the cost of timing control.

The JobScheduler supports batch scheduling of jobs. The Android system can combine jobs for reducing battery consumption. JobManager automatically handles the network unreliability so it makes handling uploads easier.

Here is some example of a situation where you would use this job scheduler:

Tasks that should be done when the device is connected to a power supply.

Tasks that require a Wi-Fi connection or network access.

Tasks should run on a regular basis as a batch where the timing is not critical.

37. What is the difference between onDestroy and onDestroyView in a fragment?

In Android fragments, onDestroy() and onDestroyView() are two different lifecycle methods that are called when the fragment is being destroyed.

onDestroyView() is called when the fragment’s view is being destroyed, typically as a result of the fragment being removed from the screen or replaced by another fragment. This method is usually where you should clean up any references to views or resources that the fragment holds, such as by unregistering listeners or releasing memory-intensive objects. After this method is called, the fragment’s view hierarchy is no longer accessible.

On the other hand, onDestroy() is called when the fragment is being destroyed completely and is no longer associated with its activity. This method is usually where you should clean up any remaining resources that the fragment holds, such as by releasing system resources or closing database connections. Once this method is called, the fragment is no longer attached to its activity and cannot be used again without being re-created.

In summary, onDestroyView() is called when the fragment’s view is being destroyed and onDestroy() is called when the fragment itself is being destroyed.

38. What is the difference between onCreate and onCreateView in a fragment?

onCreate() is called when the fragment is first created, and it is used to perform any setup or initialization that should happen before the fragment’s UI is created. This method is typically used to set up things like data structures, listeners, and other objects that will be needed later.

onCreateView() is called when it’s time to create the fragment’s UI. This method is responsible for inflating the fragment’s layout, creating any UI elements that are needed, and returning the root view of the fragment. This method should not be used for any initialization or setup that should happen before the UI is created, as that should be done in onCreate().

In summary, onCreate() is called before the UI is created and is used for initialization and setup, while onCreateView() is called to create the fragment’s UI and should be used for inflating the layout and creating the UI elements.

39. Different ways to pass data between Activities and Fragments

1. Activity to Activity:
Intent with extras: You can pass data between activities using intents with extras. You can put extras in the intent object and retrieve them in the target activity using getIntent().getExtras().
Parcelable or Serializable: You can also make your custom data model implement the Parcelable or Serializable interface and pass it in the intent as an extra.
Static Variables: You can also use static variables to pass data between activities, but this is not recommended as it can lead to memory leaks and other issues.

2. Fragment to Fragment:
Bundle: You can pass data between fragments using a Bundle. You can create a Bundle object and set data in it, then set the Bundle as the arguments for the target fragment using setArguments() method.
ViewModel: You can also use a shared ViewModel to share data between fragments.

3. Fragment to Activity:
Interface: You can define an interface in the Fragment and implement it in the Activity. The Fragment can then call the interface method to pass data to the Activity.
Intent with extras: You can also pass data from a Fragment to an Activity using an intent with extras.

4. Activity to Fragment:
Interface: You can define an interface in the Activity and implement it in the Fragment. The Activity can then call the interface method to pass data to the Fragment.
Bundle: You can pass data from an Activity to a Fragment using a Bundle. You can create a Bundle object and set data in it, then set the Bundle as the arguments for the target fragment using setArguments() method.
ViewModel: You can also use a shared ViewModel to share data between the Activity and Fragment.

40. When Activity B is launched from the onCreate() method of Activity A and the back button is pressed to return to Activity A, the following activity lifecycle methods are typically called:

When Activity B is launched:
onPause() is called on Activity A as it is no longer in the foreground and loses focus.
onCreate() is called on Activity B to initialise the new Activity and prepare it for display.
onStart() is called on Activity B to indicate that the Activity is about to become visible to the user.
onResume() is called on Activity B when it becomes the foreground Activity and gains focus.

onPause() is called on Activity B as it is no longer in the foreground and loses focus.
onStop() may be called on Activity B if it is no longer visible to the user.
onRestart() is called on Activity A as it is about to be brought back to the foreground.
onStart() is called on Activity A to indicate that it is about to become visible to the user.
onResume() is called on Activity A when it becomes the foreground Activity and gains focus.

Note: that if Activity B calls finish() to exit the Activity rather than pressing the back button, then the activity lifecycle methods for returning to Activity A will be different. In that case, onStop() will be called on Activity B followed by onRestart(), onStart(), and onResume() on Activity A.

41. What is an Activity in Android and how does it differ from a Service or a BroadcastReceiver?

An Activity: is a user interface component that represents a single screen with a user interface. It is a core component of Android applications that allows users to interact with the application, perform actions and view information on the screen. Activities can be launched by other activities or by the operating system, and can be used to display dialogs, notifications, and menus.

A Service: on the other hand, is a component that runs in the background, without any user interface. It performs long-running operations, such as playing music or downloading files, even if the application is not currently in the foreground. Services can be started, stopped or bound to other components, such as activities.

A BroadcastReceiver: is a component that allows an application to receive system-wide broadcast events, such as a battery low warning or a network connectivity change. It is not a user interface component and can’t interact with the user directly. A BroadcastReceiver can be registered to listen to specific broadcast events, and then execute code when those events occur.

In summary, Activities are used for user interaction, Services are used for background tasks, and BroadcastReceivers are used to receive system-wide events. Each of these components plays a different role in an Android application, but they can interact with each other to create complex applications.

42. JetPack components -

Android Jetpack is a set of Android components developed by Google, which was first announced at Google I/O in 2018. It was developed by a team of engineers at Google led by Stephanie Saad Cuthbertson.

Android Jetpack is intended to make it easier and faster to build high-quality Android apps, by providing a set of components that handle common app development tasks. The Jetpack components are compatible with Android API level 14 and higher, and can be used with the Java programming language or with Kotlin, a programming language developed by JetBrains and officially supported by Google for Android app development.

Overall, Android Jetpack provides a more modern and streamlined approach to Android app development, which helps developers to build better apps more quickly and efficiently.

43. Is android studio developed by google

Yes, Android Studio is developed and maintained by Google. It is the official Integrated Development Environment (IDE) for Android app development, and it provides a comprehensive set of tools and features to help developers create high-quality Android apps.

Android Studio is based on the IntelliJ IDEA IDE, which is developed by JetBrains. Google worked closely with JetBrains to customize IntelliJ IDEA specifically for Android app development, adding features and tools that are specific to the Android platform.

44. JetPack Architecture

here is an example of how you could structure an Android app using the three-layer architecture and the Android architecture components provided by Jetpack.

  1. UI layer:

In this layer, we will create the UI components like activities, fragments, and views that will be responsible for displaying the app’s user interface to the user.

class MainActivity : AppCompatActivity() {

private lateinit var viewModel: MainViewModel

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
viewModel.loadData()
viewModel.data.observe(this, Observer {
// Update UI with new data
})
}
}

In the above code, MainActivity is a UI component that observes the data property of the MainViewModel and updates the UI when the data changes. The MainViewModel will be responsible for loading the data from the data layer and exposing it to the UI layer.

2. Domain layer:

In this layer, we will define the business logic of the app. This layer should not have any knowledge of Android-specific classes or concepts.

class DataProcessor(private val repository: DataRepository) {

fun processData(data: String): String {
// Perform some business logic on the data
return repository.saveData(data)
}
}

In the above code, DataProcessor is a class that defines some business logic for processing data. It takes a DataRepository as a constructor parameter to save the data to the data layer.

3. Data layer:

In this layer, we will create the repositories, data sources, and network clients that will be responsible for managing the app’s data.

interface DataRepository {
fun saveData(data: String): String
}

class LocalDataRepository(private val dataDao: DataDao) : DataRepository {

override fun saveData(data: String): String {
dataDao.saveData(data)
return data
}
}

@Dao
interface DataDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun saveData(data: String)
}

In the above code, DataRepository is an interface that defines the methods for saving data to the data layer. LocalDataRepository is an implementation of DataRepository that saves data to a local database using Room.

By using this three-layer architecture with Jetpack architecture components, we can create a modular, maintainable, and easy-to-test Android app. The separation of concerns makes it easier to make changes to one layer without affecting the others, and the use of architecture components provides a consistent and standardized approach to app development.

46. What is the difference between Taost and Snackbar in Android -

Toast and Snackbar are both user interface components in Android that are used to display messages or notifications to the user. However, there are some differences between them:

  1. Duration: Toast is a short-lived message that disappears after a few seconds, whereas Snackbar is a more persistent message that stays until the user dismisses it or performs an action.
  2. Position: Toast can be positioned anywhere on the screen, while Snackbar is usually anchored to the bottom of the screen.
  3. Interaction: Snackbar provides a call-to-action button that allows the user to perform an action, while Toast does not.
  4. Usage: Toast is generally used to display quick, non-critical messages, while Snackbar is used for more important messages that require user attention.
  5. Styling: Snackbar can be customized with colors, fonts, and animations to match the app’s design, while Toast is limited in its styling options.

In summary, Toast is a simple and lightweight way to display messages to the user, while Snackbar offers more interactivity and customization options. The choice of which one to use depends on the context and purpose of the message.

Toast : Toast.LENGTH_SHORT — 2 seconds, Toast.LENGTH_LONG — 3.5 seconds => Toast.makeText(context, “Hello, World!”, Toast.LENGTH_SHORT).show();

SnackBar: Snackbar.LENGTH_SHORT — 2.5 seconds, Snackbar.LENGTH_LONG — 4.5 seconds

47. What are some of the basic components of an Android application and how do they interact with each other?

An Android application consists of several components that work together to provide a complete user experience. The four basic components of an Android application are:

  1. Activities: As mentioned earlier, activities are user interface components that represent a single screen with a user interface. They are the main entry point for the user to interact with the application.
  2. Services: Services are background components that perform long-running tasks, such as downloading files or playing music, that do not require user interaction.
  3. Broadcast Receivers: Broadcast Receivers are components that respond to system-wide events such as low battery, network connectivity changes, and incoming calls.
  4. Content Providers: Content Providers are components that manage the application’s data and allow other applications to access that data securely.

These components interact with each other in several ways:

  1. Activities can start other activities, services, or broadcast receivers.
  2. Services can start activities or other services, or communicate with them through an inter-process communication (IPC) mechanism.
  3. Broadcast receivers can start services or activities or pass data to other components.
  4. Content providers can be accessed by other components, such as activities or services, to get or set data.

In summary, the components of an Android application work together to provide a rich and seamless user experience by interacting with each other to perform specific tasks.

48. What are some common design patterns used in Android development and why are they important?

Design patterns are reusable solutions to common software development problems. In Android development, there are several common design patterns that are widely used by developers. Some of the most common design patterns used in Android development are:

  1. Model-View-Controller (MVC): MVC is a design pattern that separates an application into three interconnected components: the Model, View, and Controller. The Model represents the data and business logic of the application, the View displays the data to the user, and the Controller handles user input and updates the Model and View accordingly.
  2. Model-View-Presenter (MVP): MVP is a design pattern that separates an application into three interconnected components: the Model, View, and Presenter. The Model represents the data and business logic of the application, the View displays the data to the user, and the Presenter handles user input and updates the Model and View accordingly. The main difference between MVP and MVC is that the Presenter acts as an intermediary between the View and Model, whereas the Controller in MVC is responsible for updating the View directly.
  3. Model-View-ViewModel (MVVM): MVVM is a design pattern that separates an application into three interconnected components: the Model, View, and ViewModel. The Model represents the data and business logic of the application, the View displays the data to the user, and the ViewModel provides a bridge between the Model and View, handling user input and updating the Model and View accordingly. MVVM is especially useful in applications that require data binding between the View and ViewModel.
  4. Singleton: Singleton is a design pattern that ensures that only one instance of a class is created and provides a global point of access to that instance. In Android, Singleton is commonly used to create a global application context or a database helper class that needs to be accessed from multiple components.

Design patterns are important in Android development because they provide a structured and standardized way of solving common problems, making code easier to understand, maintain, and modify. By using design patterns, developers can avoid common mistakes, improve code quality, and reduce development time and costs.

49. Why jetpack came into android and what is the use of it list few jetpack components?

2018 — Jet Compose

Jetpack is a set of Android libraries and tools developed by Google to help Android developers build high-quality, robust, and scalable applications more easily and efficiently. It was introduced to address the challenges that Android developers face in building complex applications by providing a set of modular, well-architected, and well-documented components that can be easily integrated into any Android application.

Some of the key benefits of using Jetpack include:
1. Simplified development: Jetpack provides a set of pre-built components that developers can use to quickly and easily add common functionality to their Android apps, such as navigation, database access, and UI design.

2. Increased productivity: By providing common solutions to common problems, Jetpack can help developers write code faster and with fewer errors, reducing development time and cost.

3. Improved performance: Jetpack components are designed to be modular and efficient, allowing developers to build high-performing applications that are optimized for different device configurations and user experiences.

4. Better compatibility: Jetpack is designed to work with all versions of Android, including older versions, making it easier for developers to create applications that work seamlessly across multiple Android devices.

Some of the Jetpack components include:

  1. Navigation — a component for building navigation workflows in Android apps.
  2. LiveData — a component that provides observable data that can be used to update UI components.
  3. ViewModel — a component that provides a way to manage UI-related data across configuration changes and lifecycle events.
  4. Room — a component that provides an abstraction layer over SQLite to allow for easier database access.
  5. WorkManager — a component for scheduling and executing deferrable, asynchronous tasks in Android.
  6. Paging — a component for loading and displaying large data sets efficiently, with support for infinite scrolling.
  7. DataBinding — a component that allows developers to bind UI components to data sources in a declarative way, reducing boilerplate code.
  8. Android KTX — a set of Kotlin extensions for Android that makes it easier to write concise and idiomatic Kotlin code.

50. Why you are choosing career in Android? What makes you can be an Android Application Developer?

Still figuring out…!😁

--

--

Deepak Kaligotla

I’m jobless, have 5.5 yrs experience in IT Tech support/helpdesk. Love learning and developing Mobile applications (Android & iOs). Contact me if you can hire