Android Interview


1) What is Android?

Answer: Android is an operating system based on the Linux and it is the operating system for the mobile phones, tablets etc.

2) Define the Google Android SDK?

Answer: It is like a tool that provides the facility to write the code for the android application. It has the GUI which is used to emulate an android driven handheld environment and also allows to developer to test and debug the code.

3) List the components of the Android Architecture?

Answer: Android Architecture is the combination of 4 key components which are as follows:
  • Linux Kernel
  • Libraries
  • Android Framework
  • Android Application
4) Give short note on the Android Framework?

Answer: The android framework is the important factor of the android architecture. In this, all the classes and their methods are available that developers want to write the code on the android environment.

5) Define the term AAPT?

Answer: AAPT stands for Android Asset Packaging Tool. This tool provides the facility such as developers can deal with zip-compatible archives and can also creating, extracting and can see its contents.

6) Explain the importance of having an emulator within the Android environment?

Answer: The importance of having the emulator within the android environment is that developer can test codes and can able to debug the code. It has the importance when our phone is not connected to the machine to test the application.

7) Define the use of an activityCreator?

Answer: It is the first step when we create any new project. In this, shell script is used to create the new file system structure which is used to write the code in the Android IDE.

8) Explain Activities.

Answer: Activities are the user interface in the android. It is like a java frame. We can use the activities to take input from the user in the form of edit text.

9) Why we use Intents?

Answer: Intents are used to show the notification message to the user. Intent can be used to alert the user for a particular task. Using intent, we can transfer the data of one activity to another.

10) Differentiate Activities from Services.

Answer: We can close the activities when we want to wish; whereas we cannot close the service because it runs on the background.

11) What items are important in every Android project?

Answer: When any android project is created then these items are present each time. These items are AndroidManifest.xml, build.xml, bin/, src/, res/, assets/
12) Define the importance of XML-based layouts?

Answer: The xml based layout provides an easy way to setting the GUI components by using the drag and drop facility, and can set the properties via the property window, these layouts are present in the xml file and the other items are placed in the source file.

13) Explain android containers?

Answer: As the name shows, it holds the objects and widgets that are used to make the GUI and provide the arrangement for which items in the particular way that is wanted. It can hold all the controls present in the Palette.

14) What is Orientation in android?

Answer: Orientation means which style we want for our GUI form means horizontal or vertical. We can set the orientation using the setOrientation() method. 15) Define the importance of Android in the mobile market?

Answer: In the current era, android is the most popular platform, developer can write the android application and can register which will run under the android environment and developer can make the account on the Google play and publish the android application which will run on the android devices, and anyone can download application and run.

16) Give the disadvantage of Android?

Answer: The biggest disadvantage of the android device is that there is no clear described that when one application is running on machine and that application may run on different android versions or may not run on other version.

17) What is adb in android?

Answer: ADB stands for Android Debug Bridge. It provides the facility to the developer can execute the remote shell commands. It is used to control the communication towards and from the emulator port.

18) What are the various states of an activity?

Answer: Active – when activity is at the foreground means display to the user.

Paused – when activity is at the background and still visible to the user.

Stopped – when activity is non-visible and therefore is hidden or obscured by another activity
Destroyed – when the activity process is killed or completed terminated or exit.

19) Define term ANR?

Answer: ANR stands for Application Not Responding. It is a dialog which appears to the user when application is not responding for a long period of time. 20) How escape characters are used as attribute?

Answer: We can use escapes characters by using with prefixed double backslash. For example, if we want to use new line character then we will use ‘\\n’.
21) What is the importance of settings permissions in app development?

Answer: Permissions are used to allow the various restrictions to protect the data and code also. If we do not provide the permission then codes can be compromised and resulting to defects in code.
22) What data types are supported by AIDL?

Answer: AIDL provides the support for the various data types such as string, charSequence, List, Map and all the java native data types means int, long, float etc.
23) What is a Fragment?

Answer: A fragment can be a part of the activity or can be the portion of the activity, whenever we see the several parts on the screen then it is known as the fragment. Fragment is reusable.
24) What is a visible activity?

Answer: When any dialog box is appear on the screen then one activity is display behind it then this activity is called as visible activity because it is visible to the end user but not necessarily being in the foreground itself.
25) Is it possible to use or add a fragment without using a user interface?

Answer: Yes, it is possible to use or add the a fragment; when we want to develop the background behavior for any activity, then we can add the fragment by using add(Fragment string) method to add the fragment from particular activity.
26) Give the name of the core components under the Android application architecture?

Answer: The components of the core components under the android application architecture are services, intent, resource externalization, notifications, and content providers.
27) Define portable Wi-Fi hotspot?

Answer: Portable Wi-Fi spot provides the facility to share the mobile internet connection to other enables wireless devices such as using our android phone internet hotspot we can connect our laptop to use the internet.
28) What language we can use to develop the android application?

Answer: The most popular language used for the android application development is java.

29) What Virtual Machine Android runs on?

Answer: Android runs on Dalvik virtual machine.

30) Define manifest file?

Answer: It is an xml file that is associated with each android application which is used to describe the various activities, intents, filters etc. used in the android application.
31) List the name of dialog boxes supported by the Android?

Answer: Android supports the four types of dialog boxes. These are AlertDialog, ProgressDialog, DatePickerDialog, and TimePickerDialog.

32) How can we download the application from the Google play store?

Answer: To download the apps from the Google play store, we have to sign in with the Google id means Gmail id then we can get access the application from the Google play store.

33) How to select more than one option from list in android xml file, give one example.

Answer: First of all we have to specify android id, layout height and width of the list view as following example.



34) What is used to make a multiple choice list with a custom view for each row?Explain in short?

Answer: We can use the multiple choice facility in the custom view by using the checkbox and provide it to id and use it to select the multi choice and this is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.

35) Define Fragmentation?

Answer: It is a process in which IP packets are broken in to smaller parts. The fragmentation is used when the diagram has more size than the MTU (Maximum Time Unit) then each fragment become a datagram and transfer like a thread independently from the source to destination, when it is received then they are assembled.

36) What role is played by the Dalvik in android?

Answer: Dalvik works like a virtual machine and used to run the android applications, using the dalvik, an application can execute the multiple virtual machines to provide the better memory management.

37) Explain the proper way of setting up an Android-powered device for app development?

Answer: These steps are as follows:
  • First of all declare application as debuggable in the manifest file.
  • Then we have to turn on the USB Debugging in the device.
  • In the end, we have to set up the system to detect the device.
38) What are the steps in creating a bounded service through AIDL?

Answer: ?First of all we have to create the .aidl file which is used to define the user interface.

  • After that we have to implement the interface that invokes extending the inner abstract Stub class and its implementing methods.
  • Now we have to expose the interface which involves implementing the services for the customers.
39) What is the importance of Default Resources in android?

Answer: When we define ant name of the controls then these names are registered into the default resource file, if it is not present then application give error and the application will never run without this fie.

40) When we deal with multiple resources, which one takes precedence?

Answer: When we deal with multiple resources then these multiple resources are able to match the configuration of the device. The locale qualifier takes the highest precedence over the other resources.

41) How can we remove icons and widgets from the main screen of the Android device?

Answer: To remove the icon and the shortcut, we have to press and hold that icon that we want to remove; then drag it downwards to the lower part of the activity where the remove button appears then we can remove it.

42) What composes Android application project?

Answer: The overall result of the android application is the .apk file. It is made up of the manifest file, application code, resource files and other related files to the application.

43) Define Sticky Intent?

Answer: It is like a broadcast from the method sendStickyBroadcast() and it allows to collect the data from it.

44) What is file in android?

Answer: In android, file is a block of the information, or resources for storing the information. The file can be of any type.

45) What is class in android?

Answer: The class is the compiled code of java file. Android use this file to produce the executable android file means apk file.

46) What is .dex file in android?

Answer: When any android programs compiles then it compiles in the form of dalvik executable file or .dex file then these files are zipped which forms the .apk file.

47) On which software, we can develop android apps?

Answer: Using Android Studio or Eclipse IDE, we can develop android applications.

48) What is OHA?

Answer: OHA stands for Open Handset Alliance. It is the group of the companies such as Samsung, Sony, Google Inc etc.

49) Give some name of the android versions?

Answer: Cupcake, Gingerbeard, Lollipop, Ice-Cream Sandwitch, Jelly bean etc.

50) Why we use Android?

Answer: There are several reasons to use the android because it provides market sharing, open platform, compatibility etc.

51) What is workspace in android?

Workspace is the place where the application folders are created when we start any project means when we create any application then here our project is saved.

52) What is Project Explorer in Android?

Answer: Project Explorer is the place where all the things related to the application is required such as java file, layout, resources etc are placed inside the project explorer.

53) What is Palette in android?

Answer: It is window where all the controls are placed such as TextView, Button etc.

54) What is TextFields in android?

Answer: Using text fields, we can take the input from the user. Basically it is used to take the input from the user.

55) What is AVD in Android?

Answer: AVD is a virtual Android device which is able to perform such operation like walk, talks, and act like a physical Android device.
56) What is layout in android?

Answer: In android, layout provides the way for arranging the elements on the screen or on the activity.

57) What is the use of Absolute layout in android?

Answer: It is used place the elements or controls at an absolute position. In this layout, we have to specify the x coordinate and y coordinate values for the each control.

58) What is the use of frame layout in android?

Answer: In android, frame layout is used to place a single item at a time on the screen. We can have more than one items within the frame layout but in this case, each element will be positioned based on the top lest on the screen.

59) What is the use of linear layout in android?

Answer: Linear layout is used to organize the elements along a single line. We can define the line either horizontal or vertical using the android:orientation attribute.

60) What is the use of relative layout in android?

Answer: It is used to display the view elements at the relative position. Each view element can be place based on the relationship with another and its parent container. We can define the position of new view in the relation of the current view.

61) What is the use of Table layout in android?

Answer: It is used to organize the content in the form of row and column. The rows are defined in the android layout XML and the columns are defined by the android system automatically.

61) What is Android Toast?

Answer: In android, toast is like a notification or like a simple popup message that appears on the screen and disappears automatically after some time.

62) How to use Toast in Android?

Answer: To use the toast, first we have to create the instantiate of the Toast with the makeText() method. This method takes three arguments: the application Context, the text message, and time duration for the toast for display on the screen. It returns an initialized Toast object. show() method is used to show the toast notification on the current activity.

63) Write the syntax to use the Toast in application?

Answer:
Context context = getApplicationContext();
CharSequence text = “Hello eitworld”;
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeToast(context,text,duration);
toast.show();
// another way to use this toast
Toast.makeText(context,text,duration).show();
In the above example, first we have declared the instance of the Context and initialized with the current application context. getApplicationContext() method is used to get the application context. After that we have assigned a message into text of CharSequence type. Then we have specified the time duration for the message and Toast.LENGTH_LONG is used for time limit and assigned to the duration of type int. show() method id used to show the toast message on the current activity.

64) Why we use button in Android?

Answer: Button is used to perform any action when we click on the button. In android, when we want to perform any action on button click then we have to provide the code or functionality.

65) What is Android Notification?

Answer: Android notification is used to show the message or email when any new message comes to mobile phone then the message icon is displayed on the top of the mobile screen. It is called as notification.

66) Where android notification is displayed?

Answer: In most devices, the notification drawer is placed at the top of the device but we can set the notification drawer at the bottom of the device by changing the setting of the notification drawer.

67) What can be the possible options on the notification drawer?

Answer: When we swipe the notification drawer from top to bottom then we can see the some icons such as Bluetooth, Wifi, screen brightness, settings icon etc. If we want to perform any action by using this then we have to click on that particular icon means if we want to change the call settings then we have to click on the setting icon then the all setting options are displayed then we can choose the call setting and we can also take other actions.

68) What are the content of the android notification?

Answer: ?Icon: it is a small icon that is used to represent the application related to the notification.

?Title: it is used to set the title of the notification which can be used to show the purpose of the notification.

?Detail Text: it is used to display the message.

69) What is Android Spinner?

Answer: In android, drop down menu is called as spinner. When we want to select one option from the given list then we can use the spinner.

70) What is Dialog in Android?

Answer: A dialog is like a small window which can appear in the front of the activity. We can take input by using the dialogs in android. Dialogs are used to show the notification which can interrupt the user and can be used to perform the short tasks which is directly related to the current activity.

71) What is ListView in Android?

Answer: Android provides a list view which contains the several options where we can select one or multiple options from the given list. In android, list can be scrollable means when the items are more than the list view then the scrolling; used to display the other list items which are not displayed on the list view.

72) Why we use adapter in Android?

Answer: In android, adaptor is used to provide the view of list items to the list view means list view gets the data to show with the help of adaptor.

73) What are the two types of Adapter in Android?

Answer: In android, there are two types of adaptor such as ArrayAdaptor and CursorAdapotor.

74) Give one difference between ArrayAdaptor and CursorAdapotor?

Answer: ArrayAdaptor is used to handle data from the array but CursorAdaptor is used to handle the data from the database.

75) Which method is called when we select the item from list?

Answer: When we select any item from the list then onListItemClick() method is called.

76) Is it possible to use the multimedia in Android?

Answer: Yes, Android provides the facility to use the sound in the application. Now days, android phones are not only used for the communicating purpose but also for the entertainment.

77) What is stage fright in Android?

Answer: In android, stage fright is a multimedia system which is provided by the Google for the android devices.

78) What are the uses of the stage fright?

Answer: By using the stage fright, we can download the media, playback the media and we can also watch the live streaming.

79) Which protocols are supported by stage fright?

Answer: Stage fright supports various types of protocols such as RTSP, HTTP.

80) How can we play sound in Android apps?

Answer: We can use the music in our application by just follow the three steps as follows:
oFirst of all we have to copy the mp3 file in to the res/raw folder.

oAfter that we have to create the object of the MediaPlayer class and we have to pass the reference of mp3 file, and after that we will call the MediaPlayer.create() method and inside this method we have to pass the current activity context and the URL of the mp3 file.

oNow we have to call the start() method with the help of MediaPlayer’s object.

oThe basic syntax to include the mp3 file in our application as follows:
MediaPlayer mp = new MediaPlayer();
MediaPlayer mp1;
mp1= mp.create(Context context, mp3 file id);
mp1.start();
oWe can use this syntax also as follows:
MediaPlayer mp1;
mp1= MediaPlayer.create(Context context, mp3 file id);
mp1.start();
oAlways use the MediaPlayer.create() method because this is static method but we can access this method by object of the MediaPlayer class.

81) What is AlertDialog in Android?

Answer: Alert Dialog is a simple alert dialog box. We can define the title for this and we can also add three buttons and can display the list of items that can be selected by the user. To create it, we have to extend the AlertDialog class object.

82) What is DatePicker Dialog in Android?

Answer: DatePicker Dialog: this type of dialog shows a window and user can select the date from this window. To create the date picker dialog, we have to extend the DatePicker class.

83) What is the use of TimePicker Dialog in Android?

Answer: Time picker dialog is used to select the time. To create this dialog, we have to extend the TimePicker class.

84) Give the name of different types of intent in Android?

Answer: There are two types of intent available in android: implicit intent and explicit intent.

85) How many types of button we can add into the alert dialog?

Answer: We can add three types of button in alert dialog which are positive button, negative button and neutral button.

86) How can we create the notification in Android?

Answer: ?To create the notification, first we have to create the object of the NotificationCompact.Builder class. It is a public class.

?We can create the notification easily by creating the object of Builder class in which we have to pass the reference of the current activity.

?After that we have to set the contents of the notification by using the builder class object.

?To set the icon for the notification, we use the setSmallIcon() method and pass the address of the icon which we want to display.

?To set the title of the notification, we use the setContentTitle() method and the pass the text stream.

?To set the message, we use the setContentText() method and pass the message in the form of string.

?After that we have to call the build() method by using the object of the NotificationCompact.Builder class. This method return a notification and loaded with that contents which we have defined.

?After that to issue the notification, we have to pass the returned build object by using the Notification class object means we have to assign the build() method into the reference variable of type Notification.

?After that we have to pass the reference of getSystemService() method to it because we cannot create the object of the NotificationManager class directly.

?Now we have to call the notify() method by using the NotificationManager class object and we have to pass the notification id as integer, and object of the Notification class.

?We can create a notification using the following syntax:
NotificationCompat.Builder ncb = new NotificationCompat.Builder(this);
//crating the builder class object
ncb.setSmallIcon(R.drawable.yourIcon); // setting the icon
ncb.setContentTitle(“notification title"); //setting title
ncb.setContextText(" notification message");// setting text
Notification noti = ncb.build(); //creating notification
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(0,noti); //showing notification
87) How to open the application when we click on android notification?

Answer: ?To open the application on notification click, we have to use the setContentIntet() method and pass the object of the PendingIndent class.

?When we create the PendingIndent class object then we have to pass the object of the Intent class. This intent is used to define the action to open the particular activity.

?Following are the syntax:
Intent yrIntent = new Intent(this,yrActivity.class);
pendingIntent pi = new pendingIntent(yrIntent);
ncb.setContentIntent(pi);
88) Where AndroidManifest.xml file is located?

Answer: Android manifest file is located on the root of the package explorer hierarchy.

89) What is the use of targetSDKVersion in Android?

Answer: The targetSdkVersion is used to define the platform on which we did the application development and the testing. The target SDK version tells the android system that there is no need to apply the compatibility to support the particular version.

90) How can we use camera in our application?

Answer: We can use the camera in our application using the android.hardware.camera.

91) What is the use of callback methods in Android?

Answer: When the system is creating activity, stopping activity, resuming activity or destroying activity, then each callback methods method provides the functionality to perform specific work for appropriate to that state change.

92) What are the methods used by Android Activity life cycle?

Answer: The activity life cycle uses the following these methods:
public class Activity extends ApplicationContext
{
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}
These all methods can be overridden and we can provide the custom code for all the methods. In Android, all the activities are initialized by the onCreate() method and onPause() method can be used for the cleanup. Whenever we are implementing these methods then we have to call the super class otherwise we will get compile time error.

93) How android displays the user interface?

Answer: In android, for every action we have to provide the valid code. For instance, the activity has no idea how it is displayed on the screen; to display the activity on the screen, we have to set the content view for the activity which we want to display on the screen. We have to use the following line to show the activity on the screen:
setContentView(R.layout.activity_main);
In this, R.layout.activity_main is the layout file. It is an xml file that is located in the res/layouts directory.

94) How to use control defined in xml into the java file in android?

Answer: To use controls, first we have to register that control in to the java file. First of all we have to declare the object for particular control and we have to register that control using the id of the control which we have defined in the xml file.

95) By default, our class extends which class in android?

Answer: By default, our class extends Activity class in android.

96) Which method is used to get the text of the edit text?

Answer: getText() method is used to get the text of the edit text which is entered by the user.

97) Which java file is the most important file in the android application?

Answer: R.java file is the most important file in the android application. If it is deleted then our application will never run and get the compile time error.

98) Is it possible to create the user interface dynamically?

Answer: Yes it is possible to create the user interface dynamically on button click or on application launching time.

99) Give some popular examples of the Android applications?

Answer: Facebook Messenger, WhatsApp, Instagram, Hike etc are the popular applications of the android.

100) is it possible to develop android application in other language except java?

Answer: Yes, we can use C# to develop the android application.