Android Interview Questions-Interview Questions and Answers Page 1 of 7 scretch.info A set of questions that I have accumulated over the years in preparation for my many Android Interviews Prep. The Application class in Android. Frequently asked Android Interview Questions with detailed answers and examples. Tips and Tricks for cracking Android interview. Happy job hunting.
|Language:||English, Spanish, Portuguese|
|Genre:||Fiction & Literature|
|ePub File Size:||20.62 MB|
|PDF File Size:||20.72 MB|
|Distribution:||Free* [*Sign up for free]|
interview, is to collect and present on a readable way questions and tips on you google something like “android interview questions” the same set is always. The caller will send this intent to Android's intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and the. Here is a list of 50 important Android Operating system interview questions with their scretch.infod is the most popular operating system used in mobile.
Here is a list of 50 important Android Operating system interview questions with their answers. Android is the most popular operating system used in mobile phones. It started a new era on mobile industry with smartphones and tablets. The main feature was its touch screen. Now most of the IT companies are working with Android Apps developments. Android is a mobile operating system which was designed and built by Google, using the Linux Kernel and intended to mainly for touchscreen mobile devices like tablets and Smartphones.
This context is available in an activity. This context is tied to the lifecycle of an activity. The activity context should be used when you are passing the context in the scope of an activity or you need the context whose lifecycle is attached to the current context. There are 3 CPU architectures in Android.
ARMv7 is the most common as it is optimised for battery consumption. ARM64 is an evolved version of that that supports bit processing for more powerful computing.
ARMx86 , is the least used for these three, since it is not battery friendly. It is more powerful than the other two. Build types define properties that Gradle uses when building and packaging your Android app. Android application architecture has the following components: Activities are basically containers or windows to the user interface. If finish is called in the OnCreate method of an activity, the system will invoke onDestroy method directly.
As onCreate of an Activity is called only once, this is the point where most initialisation should go. It is inefficient to set the content in onResume or onStart which are called multiple times as the setContentView is a heavy operation. OnRestoreInstanceState - When activity is recreated after it was previously destroyed, we can recover the saved state from the Bundle that the system passes to the activity.
Both the onCreate and onRestoreInstanceState callback methods receive the same Bundle that contains the instance state information. But because the onCreate method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it.
If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed. When the screen is rotated, the current instance of activity is destroyed a new instance of the Activity is created in the new orientation.
The onRestart method is invoked first when a screen is rotated. The other lifecycle methods get invoked in the similar flow as they were when the activity was first created.
The Activity launched by intent becomes the new root of the otherwise empty task list. A ContentProvider provides data from one application to another, when requested. It manages access to a structured set of data. It provides mechanisms for defining data security.
ContentProvider is the standard interface that connects data in one process with code running in another process. The provider object receives data requests from clients, performs the requested action, and returns the results. Start by making sure your Android application has the necessary read access permissions.
Then, get access to the ContentResolver object by calling getContentResolver on the Context object, and retrieving the data by constructing a query using ContentResolver. The ContentResolver. A Service is an application component that can perform long-running operations in the background, and it doesn't provide a user interface.
It can run in the background, even when the user is not interacting with your application. These are the three different types of services: Handlers are objects for managing threads. It receives messages and writes code on how to handle the message. Job Scheduling api, as the name suggests, allows to schedule jobs while letting the system optimize based on memory, power, and connectivity conditions. The JobScheduler supports batch scheduling of jobs. The Android system can combine jobs so that battery consumption is reduced.
JobManager makes handling uploads easier as it handles automatically the unreliability of the network. It also survives application restarts. Some scenarios: An AsyncTask is not tied to the life cycle of the Activity that contains it. So, for example, if you start an AsyncTask inside an Activity and the user rotates the device, the Activity will be destroyed and a new Activity instance will be created but the AsyncTask will not die but instead goes on living until it completes.
Then, when the AsyncTask does complete, rather than updating the UI of the new Activity, it updates the former instance of the Activity i. This can lead to an Exception of the type java. View not attached to window manager if you use, for instance, findViewById to retrieve a view inside the Activity.
For these reasons, using AsyncTasks for long-running background tasks is generally a bad idea. Rather, for long-running background tasks, a different mechanism such as a service should be employed.
AsyncTasks by default run on a single thread using a serial executor, meaning it has only 1 thread and each task runs one after the other. Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.
This will happen for example when it goes in the background and there is not enough memory to keep as many background processes running as desired. Android can reclaim memory for from your app in several ways or kill your app entirely if necessary to free up memory for critical tasks. The provided onTrimMemory callback method allows your app to listen for memory related events when your app is in either the foreground or the background, and then release objects in response to app lifecycle or system events that indicate the system needs to reclaim memory.
A bound service is a service that allows other android components like activity to bind to it and send and receive data. A bound service is a service that can be used not only by components running in the same process as local service, but activities and services, running in different processes, can bind to it and send and receive data. Implementing Android bound service with Android Messenger.
Creating and destroying threads has a high CPU usage, so when we need to perform lots of small, simple tasks concurrently, the overhead of creating our own threads can take up a significant portion of the CPU cycles and severely affect the final response time. ThreadPool consists of a task queue and a group of worker threads, which allows it to run multiple parallel instances of a task.
How to disallow serialization? We can declare the variable as transient. Serializable is a standard Java interface. Parcelable is an Android specific interface where you implement the serialization yourself. It was created to be far more efficient than Serializable The problem with this approach is that reflection is used and it is a slow process.
This mechanism also tends to create a lot of temporary objects and cause quite a bit of garbage collection. Services is a component that is used to perform operations on the background.
It does not have an UI. We need to register a LocalBroadcastReceiver in the activity. And send a broadcast with the data using intents from the background service.
As long as the activity is in the foreground, the UI will be updated from the background. Ensure to unregister the broadcast receiver in the onStop method of the activity to avoid memory leaks.
We can also register a Handler and pass data using Handlers. You can find more details on how to implement here. Intents are messages that can be used to pass information to the various components of android. For instance, launch an activity, open a webview etc. Two types of intents-. Sticky Intents allows communication between a function and a service. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
If you want someone to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent. Description of the intent. Fragment is a UI entity attached to Activity. Fragments can be reused by attaching in different activities. Activity can have multiple fragments attached to it.
It contains a graphical interface that emulates an Android driven handheld environment, allowing them to test and debug their codes. What is the Android Architecture?
Android Architecture is made up of 4 key components: What is AAPT? This tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents.
What is the use of an activityCreator? An activityCreator is the first step towards the creation of a new Android project. It is made up of a shell script that will be used to create new file system structure necessary for writing codes within the Android IDE.
Differentiate Activities from Services. Activities can be closed, or terminated anytime the user wishes. On the other hand, services are designed to run behind the scenes, and can act independently.
Most services run continuously, regardless of whether there are certain or no activities being executed. What items are important in every Android project?
These are the essential items that are present each time an Android project is created: What is the importance of XML-based layouts? In common practice, layout details are placed in XML files while other items are placed in source files.
What is the importance of Android in the mobile market? Developers can write and register apps that will specifically run under the Android environment. This means that every mobile device that is Android enabled will be able to support and run these apps. With the growing popularity of Android mobile devices, developers can take advantage of this trend by creating and uploading their apps on the Android Market for distribution to anyone who wants to download it.
One app that runs on this particular version of Android OS may or may not run on another version. Another disadvantage is that since mobile devices such as phones and tabs come in different sizes and forms, it poses a challenge for developers to create apps that can adjust correctly to the right screen size and other varying features and specs.
What are the four essential states of an activity? What is the importance of settings permissions in app development? Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting to defects in functionality.
What is the function of an intent filter? Because every component needs to indicate which intents they can respond to, intent filters are used to filter out intents that these components are willing to receive. One or more intent filters are possible, depending on the services and activities that is going to make use of it. Enumerate the three key loops when monitoring an activity — Entire lifetime — activity happens between onCreate and onDestroy — Visible lifetime — activity happens between onStart and onStop — Foreground lifetime — activity happens between onResume and onPause Is there a case wherein other qualifiers in multiple resources take precedence over locale?
Yes, there are actually instances wherein some qualifiers can take precedence over locale. How can the ANR be prevented? One technique that prevents the Android system from concluding a code that has been responsive for a long period of time is to create a child thread. Within the child thread, most of the actual workings of the codes can be placed, so that the main thread runs with minimal periods of unresponsive times.
What role does Dalvik play in Android development? Dalvik serves as a virtual machine, and it is where every Android application runs. Through Dalvik, a device is able to execute multiple virtual machines efficiently through better memory management.
What is the AndroidManifest. This file is essential in every application. It is declared in the root directory and contains information about the application that the Android system must know before the codes can be executed. What is the proper way of setting up an Android-powered device for app development? The following are steps to be followed prior to actual application development in an Android-powered device: Enumerate the steps in creating a bounded service through AIDL.
What is the importance of Default Resources? When default resources, which contain default strings and files, are not present, an error will occur and the app will not run.
When dealing with multiple resources, which one takes precedence? When does ANR occur? The ANR dialog is displayed to the user based on two possible conditions. One is when there is no response to an input event within 5 seconds, and the other is when a broadcast receiver is not done executing within 10 seconds.
What is AIDL? AIDL, or Android Interface Definition Language, handles the interface requirements between a client and a service so both can communicate at the same level through interprocess communication or IPC. This process involves breaking down objects into primitives that Android can understand. This part is required simply because a process cannot access the memory of the other process. What data types are supported by AIDL?
AIDL has support for the following data types: What is a Fragment? A fragment is a part or portion of an activity. It is modular in a sense that you can move around or combine with other fragments in a single activity.
Fragments are also reusable. What is a visible activity? A visible activity is one that sits behind a foreground dialog. It is actually visible to the user, but not necessarily being in the foreground itself. When is the best time to kill a foreground activity?
The foreground activity, being the most important among the other states, is only killed or terminated as a last resort, especially if it is already consuming too much memory.
When a memory paging state has been reach by a foreground activity, then it is killed so that the user interface can retain its responsiveness to the user. Is it possible to use or add a fragment without using a user interface? Yes, it is possible to do that, such as when you want to create a background behavior for a particular activity. You can do this by using add Fragment,string method to add a fragment from the activity.
How do you remove icons and widgets from the main screen of the Android device? To remove an icon or shortcut, press and hold that icon. You then drag it downwards to the lower part of the screen where a remove button appears. What are the core components under the Android application architecture?
There are 5 key components under the Android application architecture: What composes a typical Android application project? A project under Android development, upon compilation, becomes an. This apk file format is actually made up of the AndroidManifest.
What is a Sticky Intent? A Sticky Intent is a broadcast from sendStickyBroadcast method such that the intent floats around even after the broadcast, allowing others to collect data from it.
Do all mobile phones support the latest Android operating system? Some Android-powered phone allows you to upgrade to the higher Android operating system version. However, not all upgrades would allow you to get the latest version. It depends largely on the capability and specs of the phone, whether it can support the newer features available under the latest Android version.
What is portable wi-fi hotspot? Portable Wi-Fi Hotspot allows you to share your mobile internet connection to other wireless device.
For example, using your Android-powered phone as a Wi-Fi Hotspot, you can use your laptop to connect to the Internet using that access point. In Android development, an action is what the intent sender wants to do or expected to get as a response. Most application functionality is based on the intended action. What is the difference between a regular bitmap and a nine-patch image?
In general, a Nine-patch image allows resizing that can be used as background or other image size requirements for the target device. The Nine-patch refers to the way you can resize the image: What language is supported by Android for application development?
The main language supported is Java programming language. Java is the most popular language for app development, which makes it ideal even for new Android developers to quickly learn to create and deploy applications in the Android environment. What are the different phases of the Activity life cycle?
As an activity transitions from state to state, it is notified of the change by calls to the following protected methods: What is an Explicit Intent? In an explicit intent, we actually specify the activity that is required to respond to the intent. In other words, we explicitly designate the target component. This is typically used for application internal messages. What is an Implicit Intent? In an implicit intent, the main power of the android design, we just declare an intent and leave it to the platform to find an activity that can respond to the intent.
Here, we do not declare the target component and hence is typically used for activating components of other applications seamlessly What is an AndroidManifest file?