10 most important interview questions of Android development

Nobanul Hasan
6 min readMar 26, 2019

--

Here is some common and important question that can ask in android developer’s interview.Every developer should know this answers .If it helps you then I will give more questions about android interviews. I am writing this because before my interview i also search for this types of article.I got some but here i sort out most important questions first.Just take a look.

1.What is ANR? Why it’s happen?

If you google this you will find the answer easily.I am just trying to help you that you can learn and find our easily.

Ans:ANR- Application Not Responding

ANR dialog displayed to the user

why it’s happen?

Ans : From Google documentation We can assume that when the app UI is stuck for 5 seconds for any functionality then ANR is occurred.

An ANR will be triggered for your app when one of the following conditions occur:

  • While your activity is in the foreground, your app has not responded to an input event or BroadcastReceiver (such as key press or screen touch events) within 5 seconds.
  • While you do not have an activity in the foreground, your BroadcastReceiver hasn't finished executing within a considerable amount of time.

Read more

2.How can you pass data Fragment to Host activity?

Ans: Create an interface for pass data from a Fragment to its host Activity. For know more about this checkout this link.

3.What is AAPT?

Ans: AAPT- Android Asset Packaging Tool

AAPT is a great tool to help you view, create, and update your APKs (as well as zip and jar files).

Read more form Google documentation

4.What is Explicit and Implicit intent?

Ans:

Explicit Intents : They are used for communication between two activities in a single application.

Example : Consider an application which has a login page consisting of two Fields (say username and password).If both are true it will lead us to a page which displays the username field which we entered before.In this case we use explicit intents because we need to change the activities and to carry data from one activity to the other activity(username field) in the same application.

Implicit Intents : They are used for communication between two activities of different applications.

Example : consider a news app which describes about an accident in which the video of accident is recorded and uploaded in Facebook. While clicking on the link given in the news app it will direct us to Facebook .In this case the communication is between an activity in news app and and an activity in Facebook app.For this purpose we use Implicit Intents.

5.What is AIDL?

Ans:AIDL (Android Interface Definition Language) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC). On Android, one process cannot normally access the memory of another process. So to talk, they need to decompose their objects into primitives that the operating system can understand, and marshall the objects across that boundary for you. The code to do that marshalling is tedious to write, so Android handles it for you with AIDL

Defining an AIDL Interface

You must define your AIDL interface in an .aidl file using the Java programming language syntax, then save it in the source code (in the src/ directory) of both the application hosting the service and any other application that binds to the service.

When you build each application that contains the .aidl file, the Android SDK tools generate an IBinder interface based on the .aidl file and save it in the project’s gen/ directory. The service must implement the IBinder interface as appropriate. The client applications can then bind to the service and call methods from the IBinder to perform IPC.

To create a bounded service using AIDL, follow these steps:

  1. Create the .aidl file

This file defines the programming interface with method signatures.

2.Implement the interface

The Android SDK tools generate an interface in the Java programming language, based on your .aidl file. This interface has an inner abstract class named Stub that extends Binder and implements methods from your AIDL interface. You must extend the Stub class and implement the methods.

3.Expose the interface to clients

Implement a Service and override onBind() to return your implementation of the Stub class.

Reference -https://stuff.mit.edu/afs/sipb/project/android/docs/guide/components/aidl.html

6.Explain activity lifecycle ? Difference between OnPause() and OnStop() ?

Ans:

Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class. The android Activity is the subclass of ContextThemeWrapper class.

An activity is the single screen in android. It is like window or frame of Java.

By the help of activity, you can place all your UI components or widgets in a single screen.

The 7 lifecycle method of Activity describes how activity will behave at different states.

Difference between OnPause() and OnStop()

Whenever some new activity occurs and occupies some partial space of the Screen. So your previously running activity is still visible to some extent. In this Case, the previously running activity is not pushed to Back Stack. So, here only onPause() method is called.

On other hands, if some new Activity occurs and occupies the full screen so that your previously running activity is disappeared. In this Case, your previously running activity is moved to Back Stack. Here, onPause() + onStop() are called.

To Summaries-

onPause()- Screen is partially covered by other new activity. The Activity is not moved to Back Stack.

onPause() + onStop()- Screen is fully covered by other new activity. The Activity is moved to Back Stack.

Know more about- Back Stack

7.What is Singleton class?

Ans: The Singleton’s purpose is to control object creation, limiting the number of objects to only one. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields. Singletons often control access to resources, such as database connections or sockets.

For example, if you have a license for only one connection for your database or your JDBC driver has trouble with multithreading, the Singleton makes sure that only one connection is made or that only one thread can access the connection at a time.

know more from this link

8.Java is pass by value or pass by reference?

Ans: Java is pass by Value

Described in this link

9.When we use content provider?

Ans:

A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access.

10. Does android support other languages than java?

Ans:Yes, an android app can be developed in C/C++ also using android NDK (Native Development Kit). It makes the performance faster. It should be used with Android SDK.

Thank you all for reading.Hope this can help you.

--

--

No responses yet