All CategoriesAndroid App Development

Top 10 Android Interview Questions and Answers

Android App Development is a constantly changing field. This requires people to quickly upgrade their skills, to fit the requirements for Android-related jobs. If you are applying for an Android job role, it is best to be prepared for any Android interview question that might come your way. We will keep you updated on Android interview questions, to suit the current industry standards.

How many android interview questions do you prepare before going for any Android Jobs? Not many right. In this article, we will explore some of the most frequently asked Android interview questions. Android is very hot nowadays as its one of the top operating system for Mobile and Smartphone and the close rival to Apple’s iOS. Android application developer job is in demand as well.  Following Android Interview Questions are very basic in nature but appear frequently on beginners or Intermediate programmer level on various Android interview. I have not provided answers

Here are top most Android Interview Questions and Answers

1. How do you handle a dysfunction in screen reorientation?

There are two ways of handling in screen reorientation issue:
⦁ If you are working in background activity, your app should perform some background activity in another thread or activity. i.e. Displaying Progress Dialog, Downloading some data from the internet, logging into your app etc. For that, you can use AsyncTask.
AsyncTask implementation is like below:

public class AsyncTaskExample extends AsyncTask<String, Integer, String> {
private final TaskListener listener;
public AsyncTaskExample(TaskListener listener) {
this.listener = listener;
}

For More Info : https://acadgild.com/blog/use-asynctask-android/
⦁ You can lock your screen Orientation
To lock your screen, you can use below step:
Permanently locking the screen orientation of the activity by giving the attribute of screenOrientation with “portrait”.

<activity
android:screenOrientation="portrait"
... />

2. How do you find memory leaks in Android applications?

For finding the Memory Leaks, you should use Android Device Monitor. Follow the below mentioned steps:
Android Studio is using Android Device Manager, So Open Android device manager(ADM).

In Left hand side of Android Device Manager, you will find your device/emulator, in which you can see a heap icon as shown below:

Now, when you are running your app, you will find the below analysis of memory, heap size and all statistics for it:

For More Info: https://acadgild.com/blog/android-devices-memory-management/

3. How do you troubleshoot a crashing application?

You should keep in mind the following steps for troubleshooting your crashing Android application:
⦁ Check your space on device:
Mobile device has limited storage for apps, which might get used to the full extent, in that case your app will crash or give some storage related error. You should check memory first.
⦁ Clear your app data day by day of usage:
You can clear your app data from application manager in Settings. For that, your particular app should have only server connection or passwords if you have given earlier. It will clear your cache memory so that you can install another apps or you can boost up your current app without crashing.
⦁ Memory Management:
You should manage memory so that your app runs well on a wide range of mobile phones. Some apps run well in Samsung Galaxy S2, but not in an HTC One M9. because both devices have a huge gap in terms of processing power and CPU speed.
⦁ Your app should not have compatibility issue:
It is not possible in Android to test an app on all running devices because of fragmentation, which means the storage space on a device is used inefficiently, reducing performance and capacity. So, if possible, test on as many physical devices as possible. And developers can test their applications on a real device by using the Remote Test Lab service

4. What are the key components in Android architecture?

There are five main components in Android Architecture:
⦁ Linux Kernel: Android runs on Linux Kernel in Android OS. It provides the core functionality of security, memory management, process management, network stack and driver model.
⦁ Android Runtime: It is a list of core libraries that provide most of the functionality available in the core libraries of the Java programming language. An Android application runs in its own process with its own instance of a Dalvik Virtual machine (DVM). The Dalvik VM relies on the Linux Kernel for the underlying functionality like threading and memory management.
⦁ Libraries: Android includes C/C++ libraries used by components of the Android system. These libraries are exposed by the application framework.
⦁ Media Libraries – It is based on Packet Video’s “OpenCORE”. These libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
⦁ Surface Manager – manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications
⦁ SGL – the underlying 2D graphics engine
⦁ 3D libraries – an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer.
⦁ SQLite – a powerful and lightweight relational database engine available to all applications
⦁ Application Framework: Android allows applications with rich content to be developed by proving all the core libraries through the application framework. Developers can access the device hardware, location information, set alarms and many more extensive features because of this ability.
⦁ Applications: Android comes with some of the standard applications like Contacts, calendar, maps, browser, SMS etc. All apps are written in Java.

5. What security best practices do you follow to secure Android App?

There are so many points we can talk about for best practicing to secure Android app. We can discuss some of them:
⦁ Implement File Permissions Carefully – Do not create files with permissions of MODE_WORLD_READABLE or MODE_WORLD_WRITABLE, otherwise anyone will be able to read and write files on your app. There will be insecure and your data can be overwritten by anybody.
⦁ Implement Intents Carefully – Intents are always being used for inter-component navigation and data sharing. You can start your service, broadcast the information, access data using ContentProviders using Intents. Improper implementation of intents can affect the functioning leading to data leakage, restricted functions and not properly worked project flow.
⦁ Check Activities – Activities are App’s Screens. An Activity can be executed by any app if it is exported and enabled. Activities have proper behavior by checking internal apps and verify carefully that they are ready to load or not. Activity can be directly invoked with data, so validation of input, whatever we are giving is recommended where we are doing operation on data.

⦁ Use Broadcasts Carefully – If no permission is set when sending a broadcast Intent, then any unprivileged app can receive the Intent unless it has an explicit destination. An attacker could take advantage of an Intent that doesn’t have any set permissions. So use permissions to protect intents in your application. Keep in mind that when you are sending the information using a broadcast intent to any component, the malicious app should be install on the target device.

⦁ Implement PendingIntents Carefully – A PendingIntent allows an app to pass an Intent to a second application that can then execute that Intent as if it were the originating app. Use PendingIntents as delayed callbacks to private BroadcastReceivers or broadcast activities, and explicitly specify the component name in the base Intent.

⦁ Implement Content Providers Carefully – Content providers allow apps to share data using a URI. So Do not give a content provider write access unless it’s absolutely necessary. Make sure that you have given a set of permissions so that apps can read

⦁ Signed Android APKs – APKs should be signed correctly with a non-expired certificate. Make sure the keystore containing the signing key is properly protected. Also, restrict access to the keystore to only those people that absolutely require it


Landing your Android Dream Job is now much easier!

Post Android Interview Questions in the comment section below.


6. How many types we can store data in Android phone, which are the better approaches in SharedPreferences and SQLite to save small data or large data?

We can store data in Android phone using the following options as below:
1. Shared Preferences
2. Internal Storage (Phone Memory)
3. External Storage (SD Card)
4. SQLite Database
5. Network Connection
As per the second question, I will prefer to use SharedPreferences for small data, because Shared Preferences are key/value pairs only. So if you want to keep track of small size of data, then it will be easy to use lightweight as compared to SQLite. You have to just define as many columns as you need. Shared Preferences data persist on device restart, and they will be removed along with an app uninstallation.

7.  What is the difference between Service, Thread and AsyncTask?

We can differentiate Service, Thread and AsyncTask as per their use.
⦁ Services are like an Activity but it has no in UI. Services are working in Background. i.e. If you want to fetch the weather information, for that you cannot create blank activity for that, so you can use Service.
⦁ A Thread is a class. It is a unit of execution who run parallel to the Main thread is important to signal that you can’t update a UI component from the main Thread. It executes the set of codes parallel to the main thread.
⦁ AsyncTask is used for handling those tasks that you cannot make to work on the main thread. For example, an HTTP request is very heavy work that cannot be handled on the main thread, so you handle the HTTP request in the AsyncTask.

8. What is the difference between .png and .9.png image extension, which one reduce the work of Android developer ? How?

The .png images are simple images which are using for simple image uploading, profile pictures, simple image customization.
Where The nine patch images are extension with .9.png format. Nine patch images allow resizing that can be used as background or other image size requirements in Android device.
The main difference with .9.png image is that Using .9.png image, You can resize the image in device because it contains 4 corners that are unscaled, 4 edges that are scaled in 1 axis and the middle one that can be scaled.

9.  How do you display Action Bar back button on all versions of Android?

You can set below line of code in MainActivity.java.
actionBar.setHomeButtonEnabled(true);
Now you can configure the Parent Activity in your AndroidManifest.xml as below:

<activity
android:name="com.example.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat" />
<activity
android:name="com.example.SecondActivity"
android:theme="@style/Theme.AppCompat" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.MainActivity" />
</activity>

You will now find the Back button in next Activity and you can click on it to navigate to the previous page/activity.Android Programming

10. Which service is used to perform IPC, when bind application to a service?

A Bound Service is used to perform Interprocess Communication(IPC). A Bound Service allows components to bind to the service, send requests, receive responses and perform IPC. A bound service is an implementation of the Service class that allows other applications to bind to it and interact with it. To provide binding for a service, you must implement the onBind() callback method.
There are some steps involved in this process:
The Service should implement a Handler instance that receives a callback (using handleMessage() for instance) for each call from the client.
The Handler is used to create a Messenger object which in itself is actually a reference to the Handler.
The Messenger creates an IBinder that the Service returns to clients from onBind().
Here is the sample code for simple service example which using Messanger interface:

public class MessengerService extends Service {
private String TAG = "MessengerService";
static final int MSG_SAY_HELLO = 1;
Messenger mMessenger = new Messenger(new TestHandler());
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_SAY_HELLO:
Bundle bundle = msg.getData();
String hello = (String) bundle.get("hello");
Toast.makeText(getApplicationContext(), hello, Toast.LENGTH_SHORT).show();
break;
default:
super.handleMessage(msg);
}
}
}
public MessengerService() {
}
@Override
public void onCreate() {
Log.d(TAG, "onCreate called");
}
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "onBind done");
return mMessenger.getBinder();
}
@Override
public boolean onUnbind(Intent intent) {
return false;
}
}

Here are some more frequently asked Android Interview questions,

  • Which application from your portfolio are you most proud of?
  • Describe a situation where you collaborated with developers and engineers to debug an application. What was your role?
  • What’s the first application you would like to design for our company?
  • Describe a situation where you designed new features to make an application run faster.
  • What resources do you use to get informed about mobile technology?
  • What’s the last application you installed on your smartphone?
Your answer for these android interview questions will help the interviewer understand your expertise with Android.
Stay Tuned to the blog for more updates on Android Interview questions & FAQ’s!!!

We hope that these Android Interview Questions and Answers have pre-charged you for your next Android Interview. Get the Ball Rolling and share your Android interview experiences in the comments below. Please do! It’s all part of our shared mission to ease Android Interviews for all prospective Android Developers.

Keep visiting www.acadgild.com for more updates on the courses.

Tags

2 Comments

  1. Thanks for this valuable questions answers. Here I want to add one more android interview question i.e. Can you deploy executable JARs on Android? Which packaging is supported by Android? No, Android platform does not support JAR deployments. Applications are packed into Android Package (.apk) using Android Asset Packaging Tool and then deployed onto Android platform. Google provides Android Development Tools for Eclipse that can be used to generate Android Package.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Close
Close