basic android interview questions with answers

1-What are the key components of Android Architecture?

Android Architecture consists of 4 key components:

  1. Linux Kernel
  2. Libraries
  3.  Android Framework
  4.  Android Applications

 2-Tell us something about nine-patch image.

  1. – The Nine-patch in the image name refers to the way the image can be resized: 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes.
  2. – A Nine-patch image allows resizing that can be used as background or other image size requirements for the target device.

3- Which dialog boxes are supported by android?

Android supports 4 dialog boxes:


  1. DatePickerDialog: The user can select the date using this dialog box.
  2. ProgressDialog: This dialog box is an extension of AlertDialog and supports adding buttons. It displays a progress wheel or bar.
  3. AlertDialog: Alert dialog box supports 0 to 3 buttons and a list of selectable elements which includes check boxes and radio buttons.
  4. TimePickerDialog: The user can select the time using this dialog box.

4- What is Dalvik Virtual Machine?

  1. It is Android’s virtual machine.
  2. It is an interpreter-only virtual machine which executes files in Dalvik Executable (.dex) format. This format is optimized for efficient storage and memory-mappable execution.
    How to send SMS in android? Explain with example.

SMS messaging is one of the basic and important applications on a mobile phone. Now days every mobile phone has SMS messaging capabilities, and nearly all users of any age know how to send and receive suchmessages. Mobile phones come with a built-in SMS application that enables you to send and receiveSMS messages. If you want to send the SMS programmatically then follow the following steps.

Sending SMS Messages Programmatically

Take a button on activity_main.xml file as follows.

<Button android:id=”@+id/btnSendSMS” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_centerVertical=”true” android:onClick=”sendmySMS” android:text=”sendSMS” />

According to above code when user clicks the button sendmySMS method will be called. sendmySMS is user defined method.

In the AndroidManifest.xml file, add the following statements


Now we write the final step. Write the given below method in MainActivity,java file

publicvoidsendmySMS(View v)
SmsManagersms = SmsManager.getDefault();
sms.sendTextMessage(“5446”, null, “Hello from careerRide”, null, null);
In this example I have used two emulator. On the first Android emulator (5446), click the Send SMSbutton to send an SMS message to the second emulator(5446).

Describe the SmsManager class in android.

SmsManager class is responsible for sending SMS from one emulator to another or device.

You cannot directly instantiate this class; instead, you call the getDefault() static method to obtain an SmsManager object. You then send the SMS message using the sendTextMessage() method:

SmsManagersms = SmsManager.getDefault();

sms.sendTextMessage(“5556”, null, “Hello from careerRide”, null, null);

sendTextMessage() method takes five argument.

  • destinationAddress — Phone number of the recipient.
  • scAddress — Service center address; you can use null also.
  • text — Content of the SMS message that you want to send.
  • sentIntent — Pending intent to invoke when the message is sent.
  • deliveryIntent — Pending intent to invoke when the message has been delivered.

7-How you can use built-in Messaging within your application?

You can use an Intent object to activate the built-in Messaging service. You have to pass MIME type “”, in setType method of Intent as shown in the following given below code.

Intent intent = new Intent (android.content.Intent.ACTION_VIEW);
intent.putExtra(“address”, “5556; 5558;”);// Send the message to multiple recipient.
itent.putExtra(“sms_body”, “Hello my friends!”);

What are different data storage options are available in Android?

Different data storage options are available in Android are:

  • SharedPreferences
  • SQlite
  • ContentProvider
  • File Storage
  • Cloud Storage

8-Describe SharedPreference storage option with example.

SharedPreference is the simplest mechanism to store the data in android. You do not worry about creating the file or using files API.It stores the data in XML files. SharedPreference stores the data in key value pair.The SharedPreferences class allows you to save and retrieve key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: boolean, floats, int, longs, and strings.The data is stored in XML file in the directory data/data//shared-prefs folder.

Application of SharedPreference

  • Storing the information about number of visitors (counter).
  • Storing the date and time (when your Application is updated).
  • Storing the username and password.
  • Storing the user settings.



For storing the data we will write the following code in main activity on save button:

SharedPreferences sf=getSharedPreferences(“MyData”, MODE_PRIVATE);
SharedPreferences.Editored= sf.edit();
ed.putString(“name”, txtusername.getText().toString());
ed.putString(“pass”, txtpassword.getText().toString());

In this example I have taken two activities. The first is MainActivity and the second one is SecondActivity.When user click on save button the user name and password that you have entered in textboxes, will be stored in MyData.xml file.

Here MyData is the name of XML file .It will be created automatically for you.

MODE_PRIVATE means this file is used by your application only.

txtusernameand txtpassword are two EditText control in MainActivity.

For retrieving the data we will write the following code in SecondActiviy when user click on Load button:

Public static final String DEFAULT=”N? A”;

DEFAULT is a String type user defined global variable.If the data is not saved in XML file and user click on load button then your application will not give the error. It will show message “No Data is found”. Here name and pass are same variable that I have used in MainActivity.

SharedPreferences sf=getSharedPreferences(“MyData”, Context.MODE_PRIVATE);

String Uname=sf.getString(“name”, DEFAULT);

String UPass=sf.getString(“pass”, DEFAULT);

Toast.makeText(this, “No data is found”, Toast.LENGTH_LONG).show();



Txtpassword.setText(UPass) ;
9- What are the advantages of having an emulator within the Android environment?

– The emulator allows the developers to work around an interface which acts as if it were an actual mobile device.
– They can write, test and debug the code.
– They are safe for testing the code in early design phase

10- Tell us something about activityCreator?

1-An activityCreator is the initial step for creation of a new Android project.
2-It consists of a shell script that is used to create new file system structure required for writing codes in Android IDE.

11-What do you know about Intents?

1-Notification messages to the user from an Android enabled device can be displayed using Intents. 2-There are two types of Intents – Explicit Intent, Implicit Intent.
3-The users can respond to intents.

12-What is an Explicit Intent?

1-Explicit intent specifies the particular activity that should respond to the intent.
2-They are used for application internal messages.

13-What is an Implicit Intent?

  1. In case of Implicit Intent, an intent is just declared.
  2. It is for the platform to find an activity that can respond to it
  3. Since the target component is not declared, it is used for activating components of other applications.

14-What do intent filters do?

– There can be more than one intents, depending on the services and activities that are going to use them.
– Each component needs to tell which intents they want to respond to.
– Intent filters filter out the intents that these components are willing to respond to.

15-Where are lay out details placed? Why?

1-Layout details are placed in XML files
2-XML-based layouts provide a consistent and standard means of setting GUI definition format.

16-What do containers hold?

1-Containers hold objects and widgets in a specified arrangement.
2-They can also hold labels, fields, buttons, or child containers. .

17- What is Orientation?

1-Orientation decides if the LinearLayout should be presented in row wise or column wise fashion.
2-The values are set using setOrientation()
3-The values can be HORIZONTAL or VERTICAL

18- What is it important to set permissions in app development?

1-Certain restrictions to protect data and code can be set using permissions.
2-In absence of these permissions, codes could get compromised causing defects in functionality.

19- What is AIDL?

  1. AIDL is the abbreviation for Android Interface Definition Language.
  2. It handles the interface requirements between a client and a service to communicate at the same level through interprocess communication
  3. The process involves breaking down objects into primitives that are Android understandable.

20- What data types are supported by AIDL?

AIDL supports following data types:

  1. string
  2. List
  3. Map
  4. charSequence 
  5. int
  6. long
  7. boolean
  8. char