Android Interview Questions

Since we can't read minds, but we'll give you the next best thing: a list of most commonly asked interview questions on Android. Turn yourself into an essential Android developer to live your dream career!

  • 4.6 Rating
  • 19 Question(s)
  • 23 Mins of Read
  • 4577 Reader(s)

Advanced

The first method is called 'onCreate()', which fires when the system first creates the activity. On activity creation, the activity enters the Created state.

The last method is guaranteed called ‘onPause()’. The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed), but you should save you work/variables/state here. Other methods e.g. onStop, onDestroy may be called or not depends on the system.

Explicit intents: 

They specify which application will satisfy the intent, by supplying either the target app's package name or a fully-qualified component class name.For example, to start a component in your own app, because you know the class name of the activity or service you want to start. For example, you might start a new activity within your app in response to a user action, or start a service to download a file in the background. 

Implicit intents: 

They do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it. For example, if you want to show the user a location on a map, you can use an implicit intent to request that another capable app show a specified location on a map.

Resource file name names must contain only…

  1. lowercase a-z characters
  2. 0-9 digits
  3. Underscore character

Using 'stopService()' that a given application service will be stopped. If the service is not running, nothing happens. Otherwise, it is stopped. Note that calls to startService() are not counted -- this stops the service no matter how many times it was started.
Using 'stopSelf()' is same as 'stopService()' but used within the service to indicate system to stop itself.

Beginner

There is no direct way to terminate a thread but using the two following ways it can be done. 

  1. Calling ‘interrupt()’ method on the thread object (e.g. threadObj), this will throw an InterruptedException inside the run method of thread. This exception will indicate that we should release the resources gracefully and then exiting the ‘run’ method of thread will terminate the thread.
  2. In case if the InterruptedException is swallowed by the code or ignored as well as If inside the thread’s ‘run’ method if any looping is there, if yes then adding a method check in that loop that if this thread should exit now or not, is done by checking ‘Thread.currentThread().isInterrupted()’ that returns true and then exit the run method.

MVVM stands for Model-View-ViewModel. Android applications built using MVVM are more robust, fast, scalable and very less prone to memory leaks. In MVVM ViewModel is the key between View and Model.

Data flow Reference

The important key point about MVVM is that View has reference to the ViewModel but not in reverse and that makes the application’s UI-Components related memory leak-proof. Each View may have a dedicated ViewModel or may be shared by multiple in case of fragments to enable sharing data cross fragments of an activity. MVVM is a more suitable candidate for automated testing.

It stands for Android Run Time. ART is used for running Android applications. It uses AOT (Ahead Of Time) compilation on the device. When an APK is getting installed on the Android device, the

.dex files from the APK file will be converted to processor’s native instructions set/machine code (.art extension) and that will be stored in the app’s runtime cache directory on the device’s internal storage. This will make installation little bit longer and take more space on the device storage but it makes apps run much faster, less battery consumption, robots application debugging support and better user experience.

The recommended way going forward is using WorkManager APIs, that makes it easy to specify deferrable, asynchronous tasks and when they should run under the circumstances you choose, or recurring tasks that run at a specified interval. Internally WorkManager might use JobScheduler, Firebase-JobDispatcher, Executor, and AlarmManager for running the task.

ConstraintLayout is used to maintain the view hierarchy. It is better than the existing layout in terms of performance and a simple single level layout hierarchy. That makes the code cleaner and enables much faster drawing of the views for smooth user interaction.

Android is a ‘Linux based software stack’ created for a wide array of devices and form factors. It is open source. It has layers of major components from bottom to top as follows…

  1. The Linux Kernel: It is the foundation of the Android platform
  2. Hardware Abstraction Layer (HAL): It provides standard interfaces that expose device hardware capabilities to the higher-level Java API framework. Vendors/OEMs must explicitly extend the HAL, due to this no need to open source the vendor-specific source code.
  3. Android Runtime (ART) & Native C/C++ Libraries: ART uses Ahead-of-time (AOT) and just-in-time (JIT) compilation to run the android application and Optimized garbage collection (GC) to reclaim memory. It provides better debugging support.
  4. Java API Framework: The entire feature-set of the Android OS is available through APIs implemented using Java language. These APIs form the building blocks to create Android apps by simplifying the reuse of core, modular system components, and services, which include e.g. View System, Resource manager, Notification manager, Activity manager, Content Provider
  5. System Apps: Pre-installed a set of core apps for email, SMS messaging, calendars, internet browsing, contacts, and other apps.

A view group is a special view (but invisible) that can contain other views (child views). It is a base class for layouts and views containers.

Doze mode is also called deep sleep, introduced in Marshmallow, it prevents certain tasks from running if your device is in idle state. Doze in devices reduces power consumption by deferring background CPU and Network activity for applications.

Yes, programmatically a user interface can be created where the use case is creating dynamic UI at runtime. XML based UI is created using Android Studio, it support preview and it is better maintainable compare to programmatically created UI.

It is the foundation for any Android application. It will be in app module’s src/main/ directory for Android Studio projects. This file contains information of application package, including components of the application such as activities, services, broadcast receivers, content providers etc. It performs some other tasks also: It is responsible to protect the application to access any protected parts by provision of permissions.

A method findViewById is used to find a view that was identified by the android:id XML attribute that was processed in XML Layout file or in programmatically created layout.

  1. A layout defines the structure for a user interface in an android app, such as in an activity.
  2. All elements in the layout are built using a hierarchy of View and ViewGroup objects.
  3. A View is visible and interact-able whereas a ViewGroup is an invisible container that defines the layout structure for View and other ViewGroup objects under it.
  1. A Fragment represents a behavior or a portion of user interface.
  2. A fragment must always be hosted in an activity and the fragment's lifecycle is directly affected by the host activity's life-cycle.
  3. When a fragment is added as a part of activity layout, it lives in a ViewGroup inside the activity's view hierarchy and the fragment defines its own view layout.

An intent filter is an expression/filter in an app's manifest file that specifies the type of intents that the component would like to receive. This works based on the intent's provided action, data and category fields.

  1. A Service is an application component that can perform long-running operations in the background; it can run in a new process itself or as a part of your application’s process.
  2. It doesn't provide a user interface, but various APIs to interact with it.
  3. Another application component can start a service, and it continues to run in the background even if the user switches to another application.
  4. A component can bind to a service to interact with it and even perform interprocess communication (IPC)

Description

Since we can't read minds, but we'll give you the next best thing: a list of most commonly asked interview questions on Android. Turn yourself into an essential Android developer to live your dream career!
Levels