Android interview question/Answers for new employees , fresher , advance programmer. Android programming interview common , essential Question and answers.
1. Why to use Android?
Answer: Android is useful because: • It is simple and powerful SDK • Licensing, Distribution or Development fee is not required • Easy to Import third party Java library • Supporting platforms are - Linux, Mac Os, Windows
2. How to send SMS in android? Explain with example?
Answer: 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 <uses-permissionandroid:name=”android.permission.SEND_SMS”/> Now we write the final step. Write the given below method in MainActivity,java file publicvoidsendmySMS(View v) { SmsManagersms = SmsManager.getDefault(); sms.sendTextMessage("5556", null, "Hello from careerRide", null, null); } In this example I have used two emulator. On the first Android emulator (5554), click the Send SMSbutton to send an SMS message to the second emulator(5556).
3. What are the approaches required to share persistent user-defined objects?
Answer: Persistent objects come when there is process that is in the running state and the system can perform any action like restart or kill. If there is any data that will persist and required from another data then it is very essential to save it and share it so that if one activity is down, another activity can be performed without any hindrance. To share the complex persistent user-defined objects, it is required to have the approaches like: - Application preferences: that is used to allow the user to change the setting of preferences and make it accessible by some other objects. - Files: permissions on the files can be set so that any other file can also use and share the objects - Content providers: allow easy to follow patterns that allow the user to select the object and share it with other functions. - Database: the database can be used to store the user data and can easily link between the user and the entity that are present in it.
4. What are the differences between a domain and a workgroup?
Answer: In a domain, one or more computer can be a server to manage the network. On the other hand in a workgroup all computers are peers having no control on each other. In a domain, user doesn't need an account to logon on a specific computer if an account is available on the domain. In a work group user needs to have an account for every computer. In a domain, Computers can be on different local networks. In a work group all computers needs to be a part of the same local network.
5. What is .apk extension?
Answer: The extension for an Android package file, which typically contains all of the files related to a single Android application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.
6. What do intent filters do?
Answer: - 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.
7. What are the advantages of Android?
Answer: The following are the advantages of Android:* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android. * Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized * Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android. Components can be reused and replaced by the application framework. *Optimized DVM for mobile devices *SQLite enables to store the data in a structured manner. *Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies *The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.Features of Android Application framework enabling reuse and replacement of components Dalvik virtual machine optimized for mobile devices Integrated browser based on the open source WebKit engine Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional) SQLite for structured data storage Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) GSM Telephony (hardware dependent) Bluetooth, EDGE, 3G, and WiFi (hardware dependent) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE.
8. What is the Android Open Source Project?
Answer: We use the phrase “Android Open Source Project” or “AOSP” to refer to the people, the processes, and the source code that make up Android.The people oversee the project and develop the actual source code. The processes refer to the tools and procedures we use to manage the development of the software. The net result is the source code that you can use to build cell phone and other devices.
9. Describe the SmsManager class in android?
Answer: 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.
10. Describe android Activities in brief?
Answer: Activity provides the user interface. When you create an android application in eclipse through the wizard it asks you the name of the activity. Default name is MainActivity. You can provide any name according to the need. Basically it is a class (MainActivity) that is inherited automatically from Activity class. Mostly, applications have oneor more activities; and the main purpose of an activity is to interact with the user. Activity goes through a numberof stages, known as an activity’s life cycle. Example: packagecom.example.careerride; //Application name careerride importandroid.os.Bundle; // Default packages importandroid.app.Activity; // Default packages importandroid.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override publicbooleanonCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } When you run the application onCreate method is called automatically.
11. Describe the APK format?
Answer: The APK file is compressed the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.
12. Write a program to show the addition and removing of the package.
Answer: The package is a collection of similar or different classes that can be added or removed. The package that is added with the following parameter in the command as PACKAGE_ADDED action this allow to broadcast the message of addition to the entire system and in the same way the remove command action i.e. PACKAGE_REMOVED is used. The program that performs both the action is as follows: <receiver android:name ="com.android.samples.app.PackageReceiver"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED"/> <action android:name="android.intent.action.PACKAGE_REMOVED"/> <data android:scheme="package" /> </intent-filter> </receiver>
13. What is android?
Answer: Android is a stack of software for mobile devices which has Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine. Many Virtual Machines run efficiently by a DVM device. DVM executes Java language?s byte code which later transforms into .dex format files.
14. What are the different modes of operations used in services for Android?
Answer: There are two modes of operations that are necessary to run depending on the value returned by the startcommand(). The modes are as follows: - START_STICKY: this mode is used for the services that are explicitly started and stopped according to the need and the requirement of the user. - START_NOT_STICKY or START_REDELIEVER_INTENT: this service mode is used for services that are running only when the processing command sent to them. That means these run on the basis of the command that is passed to them by giving the instruction of execution. - Clients uses the Context.bindService() that is used to get the persistent connection for a service. To create a service that is not already running the command onCreate is used.
15. Explain in brief about the important file and folder when you create new android application?
Answer: When you create android application the following folders are created in the package explorer in eclipse which are as follows: src: Contains the .java source files for your project. You write the code for your application in this file. This file is available under the package name for your project. gen —This folder contains the R.java file. It is compiler-generated file that references all the resources found in your project. You should not modify this file. Android 4.0 library: This folder contains android.jar file, which contains all the class libraries needed for an Android application. assets: This folder contains all the information about HTML file, text files, databases, etc. bin: It contains the .apk file (Android Package) that is generated by the ADT during the build process. An .apk file is the application binary file. It contains everything needed to run an Android application. res: This folder contains all the resource file that is used byandroid application. It contains subfolders as: drawable, menu, layout, and values etc.
16. Tell us something about activityCreator?
Answer: - An activityCreator is the initial step for creation of a new Android project. - It consists of a shell script that is used to create new file system structure required for writing codes in Android IDE.
17. What are the steps that are required in Service Lifecycle?
Answer: The services allow the proper functioning of the system. - The service starts with Context.startService() function and the system will retrieve the service using onCreate() method. To start the service it calls on onStartCommand(Intent, int, int)method with proper arguments that are given by the client. - If the service is running and due to some problem the user doesn't want to run it then it uses Context.stopService()or stopSelf() method to properly implement the service for the user. - Due to multiple calls of the Context.startService() method the program doesn't do any nesting of the program and shows the stopping of the services. - Services can use the command stopSelf(int)method to stop their own service. A service doesn't stop untill all the processes are processed.
18. How is the use of web view in Android?
Answer: WebView is UI component that can display either remote web-pages or static HTML
19. What is An Activity?
Answer: Activity performs actions on the screen.If you want to do any operations, we can do with activity
20. What is the main reason of using process lifecycle in Android?
Answer: The android system will keep all the process that are hosting the services together at one place till the time the service is not started or connected to the client. The priority of the process is divided when running low on memory or when the process has to be killed. The process lifecycle is as follows: - The service is running currently then the methods onCreate(), onStartCommand(), and onDestroy()methods, will run in the foreground to execute the process without being killed. - The service is already started then the process can be considered as less important then the processes that are currently visible and used. This is done as there are only few processes that are visible to the users on the screen. - The clients are bounded to the services they are providing requires more priority in the execution list. - The service that is started uses startForeground(int, Notification)API to allow all the services to run in the foreground state. The system considers only the services where the user is still active as the services not to be killed.
21. What are the notifications available in android?
Answer: Toast Notification − It will show a pop up message on the surface of the window Status Bar Notification − It will show notifications on status bar Dialogue Notification − It is an activity related notification.
22. What is Android?
Answer: Android is a stack of software for mobile devices which includes an Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine.
23. What is the APK format?
Answer: The Android packaging key is compressed with classes,UI's, supportive assets and manifest.All files are compressed to a single file is called APK.
24. What is an Explicit Intent?
Answer: - Explicit intent specifies the particular activity that should respond to the intent. - They are used for application internal messages.
25. What is needed to make a multiple choice list with a custom view for each row?
Answer: Multiple choice list can be viewed by making the CheckBox android:id value be ''@android:id /text1". That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.
26. What?s the difference between file, class and activity in android?
Answer: File – It is a block of arbitrary information, or resource for storing information. It can be of any type. Class – Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk Activity – An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.
27. What language does android support to develop an application?
Answer: Android applications has written using the java(Android SDK) and C/C++(Android NDK).
28. What is container in android?
Answer: The container holds objects,widgets,labels,fields,icons,buttons.etc.
29. What dialog boxes are supported in android?
Answer: There are 4 dialog boxes which have been supported by Android. These are as follows: AlertDialog: it supports 0 to 3 buttons with a list of selectable elements that includes check boxes and radio buttons. -ProgressDialog: it displays the progress of any dialog or application. It is an extension of AlertDialog and supports adding buttons. -DatePickerDialog: it is used to give provision to the user to select the date - TimePickerDialog: it is used to give provision to the user to select the time
30. What is Dalvik Virtual Machine?
Answer: - It is Android's virtual machine. - 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.
31. Which kernal is used in android?
Answer: Android is customized Linux 3.6 kernel.
32. What is Drawable?
Answer: A compiled visual resource that can be used as a background, title, or other part of the screen. It is compiled into an android.graphics.drawable subclass.
33. What do you know about Intents?
Answer: - Notification messages to the user from an Android enabled device can be displayed using Intents. The users can respond to intents. - There are two types of Intents - Explicit Intent, Implicit Intent.
34. What are the steps that are involved in converting the android in newer version?
Answer: To release a new version requires lots of changes and a process has to be developed to build the changes. The steps that is required: - In the beginning of the creation the software gets the built or the earlier version of the system image. This includes various certifications and deployment rules and regulations. - The built goes through operator testing and this is one of the important phase as it allows lot of bugs to be found and corrected. - The release then goes the regulators, moderators and operators to produce the devices to release the source code. The code that is written is checked for errors and there is a sign of the agreement that take place between the contributors and some verification are performed. - The production of the software begins and the release process starts and then the release will allow the users to grab the devices.
35. How to update UI from a service in android?
Answer: Use a dynamic broadcast receiver in the activity, and send a broadcast from the service. Once the dynamic receiver is triggered update UI from that receiver.
36. What are application Widgets in android?
Answer: App Widgets are miniature application views that can embedded in other applications (such as the Home screen) and receive periodic updates. These views has referred to as Widgets in the user interface, and you can publish one with an App Widget provider.
37. What is a Theme ?
Answer: A set of properties (text size, background color, and so on) bundled together to define various default display settings. Android provides a few standard themes, listed in R.style (starting with “Theme_”).
38. What are the exceptions available in android?
Answer: InflateException,Surface.OutOfResourceException,SurfaceHolder.BadSurfaceTypeException,and WindowManager.BadTokenException
39. What is the Android Emulator?
Answer: The Android Development Tools (ADT) include an emulator to run an Android system. The emulator behaves like a real Android device (in most cases) and allows you to test your application without having a real device. You can configure the version of the Android system you would like to run, the size of the SD card, the screen resolution and other relevant settings. You can define several of them with different configurations. These devices are called Android Virtual Device and you can start several in parallel.
40. What are the different Storage Methods in android?
Answer: Android provides many options for storage of persistent data. It provides the solution according to your need. The storages which have been provided in Android are as follows:- Shared Preferences: Store private primitive data in key-value pairs Internal Storage: Store private data on the device memory. External Storage: Store public data on the shared external storage. SQLite Databases: Store structured data in a private database. Network Connection: Store data on the web with your own network server.
41. What are the methods to avoid memory leaks in Android?
Answer: Android applications are well bundled with the memory but they have a drawback of running lots of application that keeps in the memory to make the processing faster. The more application in the memory, the faster will be the switch between the applications. The memory leaks can be avoided by changing the context. The context is used for many operations but it is used to access the resources on android. The widgets have a context parameter in their constructors. There are mainly two types of context: either activity or application. The program is as follows: @Override protected void onCreate(Bundle state) { super.onCreate(state); TextView label = new TextView(this); label.setText("Test memory leak"); setContentView(label); } if the context is having leaks in it then the activity then there is a possibility of the leaks of memory. The leaking of the entire activity can be checked. The system will automatically create and destroy one of the activities by default. Android will reload the application by using the rotation policy. And it will keep the entire static field maintained.
42. Tell us something about nine-patch image.
Answer: - 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. - A Nine-patch image allows resizing that can be used as background or other image size requirements for the target device.
43. What is a Sticky Intent?
Answer: Intent is basically an abstract description of an operation that has to be performed for communication. Sticky Intent is also a type of intent which allows the communication between a function and a service. For example: sendStickyBroadcast() performs send Broadcast(Intent) which stays even after the broadcast is complete. It helps in retrieving the data quickly. The message ACTION_BATTERY_CHANGED of an operating system is an example of it.
44. What is APK format in Android? How to make an APK file?
Answer: APK termed as Application package file is a format that is used to distribute and install the application software for android, and middleware on the android operating system. To make an APK file, first android is compiled and then all of its parts are grouped in one file termed as package. The package consists of the entire program’s code (.dex files), resources, manifest file etc. The file is saved with .apk extension.
45. Define the application resource file in android?
Answer: JSON,XML bitmap.etc are application resources.You can injected these files to build process and can load them from the code.
46. What is the procedure to check status of an activity in Android?
Answer: The status of an activity can be start and stop only. The start means the activity is up and running. It is in execution state and performing some actions. Whereas the stop state defines that the activity is being stopped and performing no action on the system. To see or check the status of an activity there is a command that has to be used like NEW_TASK_LAUNCH flag that keeps the track of all the activities that are running and the main command under which the flag resides is given as startActivity() call. To bring the activity stack in front of the process that is already running require the command mentioned above to be used. The activity can be started remotely by using the remote services. These services allow easy interaction with the client and provide the sample to show it on the local server.
47. What are the different forms of communication provided by the Android applications?
Answer: There are different forms of communication that is used by the Android application developers like: - Internet telephony: this is used to add SIP-based features to the application. This includes the full SIP protocol stack and includes integrated call management services. These services allow setting the ongoing and incoming voice calls without managing the sessions at the transport level. This provides the communication to be successful by determining the associated carriers. - NFC (Near field communications) - this is used to allow the communication to happen between the developers that create the new class of application. These new applications are created and provided as a service to the users, organizations, merchants and advertisers. It allows the tagging of application that interests the user. The tag allows the user to communicate through wireless telephony services and allow the use of device hardware.
48. What is the order of dialogbox in android?
Answer: Positive, Neutral, Negative.
49. What do containers hold?
Answer: - Containers hold objects and widgets in a specified arrangement. - They can also hold labels, fields, buttons, or child containers. .
50. What is the Open Handset Alliance?
Answer: The OHA is a consortium of 84 technology and mobile companies that have joined hands to accelerate innovation in mobile technology and at the same time offer the end users a better, cost-effective and richer mobile experience. Members of this include Google, HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas Instruments, Samsung, LG, T-Mobile, Nvidia. The OHA was started on 5 November 2007 by Google and 34 other companies. Android is the main software of the alliance.
51. What is an explicit Intent?
Answer: Android Explicit intent specifies the component to be invoked from activity. In other words, we can call another activity in android by explicit intent.
52. What is An Intent?
Answer: It is connected to either the external world of application or internal world of application ,Such as, opening a pdf is an intent and connect to the web browser.etc.
53. What is an Implicit Intent?
Answer: - In case of Implicit Intent, an intent is just declared. - It is for the platform to find an activity that can respond to it. - Since the target component is not declared, it is used for activating components of other applications.
54. What is an Intent Filter ?
Answer: Activities and intent receivers include one or more filters in their manifest to describe what kinds of intents or messages they can handle or want to receive. An intent filter lists a set of requirements, such as data type, action requested, and URI format, that the Intent or message must fulfill. For Activities, Android searches for the Activity with the most closely matching valid match between the Intent and the activity filter. For messages, Android will forward a message to all receivers with matching intent filters.
55. What are the features of Android?
Answer: • Components can be reused and replaced by the application framework. • Optimized DVM for mobile devices • SQLite enables to store the data in a structured manner. • Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies • The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.
56. What are the steps required in setting up the linkify calls intent?
Answer: Linkify is used to route the intent in an activity. This linkify allows the calls to be invoked and allow an activity to be handled. The process of executing the linkfy is as follows: - linkfy is used to invoke the process in the TextView and allow the matching of the patterns to be turned into the intent links. - Linkify monitors the intent links that is being selected by the user and allow it to be modified for further actions. - Linkfy allows the user to select the link and when user selects it, it calls the VIEW action on the content that uses an URI that is associated with the link. - Android takes the content that is represented by the URI and the data that is used. It looks for the ContentProvider component that is registered with the system and matches the URI of the content that is getting produced. - If the match is found for the query done by android then the URI gets used by the ContentProvider and MIME type of data can be returned for the URI. - Android uses the activity registered in the system that uses the intent-filter matching both the VIEW action and the MIME type for the data that can be linked with the URI.
57. Write a program that shows the creation of reusable user interface that includes the layout.
Answer: The program that uses the reusable user interface including the layout is given below: <com.android.launcher.Workspace android:id="@+id/workspace" android:layout_width="fill_parent" android:layout_height="fill_parent" launcher:defaultScreen="1"> <include android:id="@+id/cell1" layout="@layout/work" /> <include android:id="@+id/cell2" layout="@layout/work" /> </com.android.launcher.Workspace> The tag that is used in this are: <include />: this is the element tag and it includes other XML layout files. It calls the layout files by using their name and including @layout. This @ defines the inclusion of layout file in the program. The same out in the example is included two times. The tag overrides some attributes that are included in the layout. The id can be added that uniquely identifies the application and the components that are used inside it.
58. How you can use built-in Messaging within your application?
Answer: You can use an Intent object to activate the built-in Messaging service. You have to pass MIME type “vnd.android-dir/mms-sms”, 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!"); intent.setType("vnd.android-dir/mms-sms"); startActivity(intent); 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
59. Which dialog boxes are supported by android?
Answer: Android supports 4 dialog boxes: a.) AlertDialog: Alert dialog box supports 0 to 3 buttons and a list of selectable elements which includes check boxes and radio buttons. b.) ProgressDialog: This dialog box is an extension of AlertDialog and supports adding buttons. It displays a progress wheel or bar. c.) DatePickerDialog: The user can select the date using this dialog box. d.) TimePickerDialog: The user can select the time using this dialog box.
60. What are the advantages of having an emulator within the Android environment?
Answer: - 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
61. Whats are assets?How to Access assets ?
Answer: While the res directory contains structured values which are known to the Android platform, the assets directory can be used to store any kind of data. You access this data via the AssetsManager which you can access the getAssets() method. The AssetsManager class allows to read a file in the assets folder as InputStream with the open() method. The following code shows an example for this. // Get the AssetManager AssetManager manager = getAssets(); // Read a Bitmap from Assets open = manager.open("logo.png"); Bitmap bitmap = BitmapFactory.decodeStream(open); // Assign the bitmap to an ImageView in this layout ImageView view = (ImageView) findViewById(R.id.imageView1); view.setImageBitmap(bitmap); } ccaattcchh (IOException e) { e.printStackTrace(); } ffiinnaallllyy { iiff (open != null) { ttrryy { open.close(); } ccaattcchh (IOException e) { e.printStackTrace(); } } }
62. Can a device have a different user interface and still becompatible?
Answer: The Android Compatibility Program focuses on whether a device can run third-party applications. The user interface components shipped with a device (such as home screen, dialer, color scheme, and so on) does not generally have much effect on third-party apps. As such, device builders are free to customize the user interface as much as they like. The Compatibility Definition Document does restrict the degree to which OEMs may alter the system user interface for areas that do impact third-party apps.
63. Describe the SmsManager class in android.
Answer: 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.
64. What are the services that can be allowed to run in a single process?
Answer: Android allows all the services and applications to run on a single process. This behavior is the default behavior that can be changed by using the different settings and functions. The process can be declared by using android: process attribute. This places the component explicitly on the process. Service is not a separate process and itself it's a process if not defined separately. The service is not used as a thread as well but it defines other threads in the program to do the work and create the application. The application runs and finds the errors in the program and the service just takes the necessary actions on them. The service also responds to the errors whenever necessary.
65. What is a Dalvik ?
Answer: The name of Android’s virtual machine. The Dalvik VM is an interpreter-only virtual machine that executes files in the Dalvik Executable (.dex) format, a format that is optimized for efficient storage and memory-mappable execution. The virtual machine is register-based, and it can run classes compiled by a Java language compiler that have been transformed into its native format using the included “dx” tool. The VM runs on top of Posix-compliant operating systems, which it relies on for underlying functionality (such as threading and low level memory management). The Dalvik core class library is intended to provide a familiar development base for those used to programming with Java Standard Edition, but it is geared specifically to the needs of a small mobile device.
66. What is the TTL (Time to Live)? Why is it required?
Answer: TTL is a value in data packet of Internet Protocol. It communicates to the network router whether or not the packet should be in the network for too long or discarded. Usually, data packets might not be transmitted to their intended destination within a stipulated period of time. The TTL value is set by a system default value which is an 8-bit binary digit field in the header of the packet. The purpose of TTL is, it would specify certain time limit in seconds, for transmitting the packet header. When the time is exhausted, the packet would be discarded. Each router receives the subtracts count, when the packet is discarded, and when it becomes zero, the router detects the discarded packets and sends a message, Internet Control Message Protocol message back to the originating host.
67. How to select more than one option from list in android xml file? Give an example.
Answer: Specify android id, layout height and width as depicted in the following example. <ListView android:id="@+id/ListView01" android:layout_height="wrap_content" android:layout_width="fill_parent"></ListView>
68. What is the difference between Service and Thread?
Answer: Service is like an Activity but has no interface. Probably if you want to fetch the weather for example you won't create a blank activity for it, for this you will use a Service. It is also known as Background Service because it performs tasks in background. A Thread is a concurrent unit of execution. You need to know that you cannot update UI from a Thread. You need to use a Handler for this
69. What is a Toast Notification?
Answer: A toast notification is a message that pops up on the surface of the window. It only fills the amount of space required for the message and the user's current activity remains visible and interactive. The notification automatically fades in and out, and does not accept interaction events. A Status Bar Notification: It is used for persistent reminders that come from the background and request the user's response. A Dialog Notification: It is Used for Activity-related notifications.
70. Explain AndroidManifest.xmlfile in detail?
Answer: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.careerride" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name="com.example.careerride.MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> The AndroidManifest.xml file contains the following information about the application: • It contains the package name of the application. • The version code of the application is 1.This value is used to identify the version number of your application. • The version name of the application is 1.0 • The android:minSdkVersion attribute of the element defines the minimum version of the OS on which the application will run. • ic_launcher.png is the default image that located in the drawable folders. • app_name defines the name of applicationand available in the strings.xml file. • It also contains the information about the activity. Its name is same as the application name.
71. What is An android manifest file?
Answer: Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.
72. Describe android Activities in brief.
Answer: Activity provides the user interface. When you create an android application in eclipse through the wizard it asks you the name of the activity. Default name is MainActivity. You can provide any name according to the need. Basically it is a class (MainActivity) that is inherited automatically from Activity class. Mostly, applications have oneor more activities; and the main purpose of an activity is to interact with the user. Activity goes through a numberof stages, known as an activity's life cycle. Example: packagecom.example.careerride; //Application name careerride importandroid.os.Bundle; // Default packages importandroid.app.Activity; // Default packages importandroid.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override publicbooleanonCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } When you run the application onCreate method is called automatically.
73. What is involved in releasing the source code for a new Androidversion?
Answer: Releasing the source code for a new version of the Android platform is a significant process. First, the software gets built into a system image for a device, and put through various forms of certification, including government regulatory certification for the regions the phones will be deployed. It also goes through operator testing. This is an important phase of the process, since it helps shake out a lot of software bugs. Once the release is approved by the regulators and operators, the manufacturer begins mass producing devices, and we turn to releasing the source code. Simultaneous to mass production the Google team kicks off several efforts to prepare the open source release. These efforts include final API changes and documentation (to reflect any changes that were made during qualification testing, for example), preparing an SDK for the new version, and launching the platform compatibility information.Also included is a final legal sign-off to release the code into open source. Just as open source contributors are required to sign a Contributors License Agreement attesting to their IP ownership of their contribution, Google too must verify that it is clear to make contributions. Starting at the time mass production begins, the software release process usually takes around a month, which often roughly places source code releases around the same time that the devices reach users.
74. What are the key components in android architecture?
Answer:
Linux Kernel
Libraries
Android Framework
Android applications.
75. Describe Briefly the Android Application Architecture?
Answer: Android application architecture allows the simplification and reuse of any application. It provides a better way to publish the capabilities of the application so that any other application can make good use of those capabilities. This architecture includes the following components: Intent: perform some operation on some activity and service Resource Externalization - such as strings and graphics Notification signaling users - light, sound, icon etc. Content Providers – sharing of data between various applications
76. What are the different data types used by Android?
Answer: The data can be passed between many services and activities using the following data types: - Primitive Data Types: are used to share the activities and services of an application by using the command as Intent.putExtras(). This primitive data passes the command to show the persistent data using the storage mechanism. These are inbuilt data types that are used with the program. They provide simple implementation of the type and easy to use commands. - Non-Persistent Objects: are used to share complex and non-persistent objects. These are user-defined data types that are used for short duration and are also recommended to be used. These types of objects allow the data to be unique but it creates a complex system and increase the delay.
77. What are the key components of Android Architecture?
Answer: Android Architecture consists of 4 key components: - Linux Kernel - Libraries - Android Framework - Android Applications
78. What is the role of Android Market in compatibility?
Answer: Devices that are Android compatible may seek to license the Android Market client software. This allows them to become part of the Android app ecosystem, by allowing users to download developers’ apps from a catalog shared by all compatible devices. This option isn’t available to devices that aren’t compatible. The Android software can be ported to a lot of different kinds of devices, including some on which third-party apps won’t run properly. The Android Compatibility Definition Document (CDD) spells out the specific device configurations that will be considered compatible. For example, though the Android source code could be ported to run on a phone that doesn’t have a camera, the CDD requires that in order to be compatible, all phones must have a camera. This allows developers to rely on a consistent set of capabilities when writing their apps.
79. What are the different phases of the Activity life cycle?
Answer: As an activity transitions from state to state, it is notified of the change by calls to the following protected methods: 1) void onCreate(Bundle savedInstanceState) 2) void onStart() 3) void onRestart() 4) void onResume() 5) void onPause() 6) void onStop() 7) void onDestroy() Taken together, these seven methods define the entire lifecycle of a