Android Interview Questions - Entry Level, Freshers
- Activities Services
- Content Providers
- Intents
- Broadcast Receivers
- Widgets
- Notifications
- Views
- Fragments
- Resources
- App APK files
- Layout XML Files
- Fragments can be added or removed in an activity while the activity is running.
- A fragment has its own layout and behavior with its own life cycle callbacks.
- Multiple fragments can be combined in a single activity to build a multi-pane UI.
- The fragment life cycle is closely related to the life cycle of its host activity which means when the activity is paused, all the fragments available in the activity will also be paused.
Storage options available in Android:
Some storage options available in Android are listed below:
- Internal Storage
- External Storage
- SQLite database
- Shared Preferences
BuildType in Gradle:
Build Type is a build and packaging settings like signing configuration for a project. For instance, debug and release build types. The debug build type will use an android debug certificate for packaging the APK file. While the release build type will use a user-defined release certificate for signing and packaging the APK.
Android Product Flavors:
Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs.
Intent in Android:
Android uses Intent for the communication between the components of an application. The intent is the object which is used in android for passing the information among Activities in an Application. It also provides connectivity between two apps.
Life cycle of an Activity:
An android application will undergo various states that are associatively called as Android Activity Life Cycle.
The lifecycle of activity consists of 7 methods:-
1. onCreate() - The function onCreate() is called When a user first opens an activity that acts the same as a constructor of a class.
2. onStart() - The function onStart() is called when an activity becomes visible to the user and is called after onCreate.
3. onResume() - The function onResume() is called just before the user starts interacting with the application.
4. onPause() - The function onPause() is called when the app is partially visible to the user on the mobile screen.
5. onStop() - The function onStop() is called when the activity is no longer on the activity stack and not visible to the user.
6. onRestart() - The function onRestart() is called when the activity in the stopped state is about to start again.
7. onDestroy() - The function onDestroy() is called when the activity is cleared from the application stack.
Difference between onCreate() and onStart()
The major difference between onCreate() and onStart() is as follows.
onCreate() is called when the Activity is created; that is, it is launched or started. (Additionally, this trigger when the orientation is changed.) It is called again when the process is killed, then returned to.
While onStart() called following onCreate() at startup. Additionally, it is also called when the app is navigated back to after onStop() (and following onRestart()), which occurs after the Activity is no longer visible (which is during the time that "the user can see the activity on-screen, though it may not be in the foreground and interacting with the user").
Is there any case where onDestoy() will be called without calling onPause() and onStop()?
When you call finish() method inside onCreate() of your Activity, then onDestroy() will be called directly.
How do you save and restore an activity's state during screen rotation?
You can use "onSavedInstanceState(bundle:Bundle)" to save the activity’s state inside a bundle. Then you can use "onRestoreInstanceState(bundle)" to restore the state of activity.
When is the onStop() method invoked?
In Android, a call to onStop() method happens when an activity is no longer visible to the user, either because another activity has taken over the control or if in front of that activity.
What is the use of FLAG_ACTIVITY_CLEAR_TASK
In Android, FLAG_ACTIVITY_CLEAR_TASK is used to end any previously existing task that helps to start new Activity in conjunction with FLAG_ACTIVITY_NEW_TASK.
Services in Android:
Services in Android are a component that acts as an application to run in the background in order to perform long-running operation tasks.
The types of Services are listed below:
(a). Background Services
(b). Foreground Services
(c). Bound Services
Use of AsyncTask:
Android AsyncTask going to do background operation on the background thread and update on the main thread. In android, we can't directly touch the background thread to the main thread in android development. asyncTask helps us to make communication between the background thread to the main thread.
What is IntentService:
IntentService is a direct subclass for Services that handle asynchronous requests on demand. Clients send requests through Context. It is born to make things easier. It is also used to perform a certain task in the background. The instance of IntentService terminates itself automatically when needed.
Handler in Android:
A Handler is used to send and process Message and Runnable objects associated with a thread's MessageQueue. When a Handler created default bound with a Looper class. It will deliver messages and runnable to that Looper's message queue and execute them on Looper's thread.
Handlers are mainly used to Update the User Interface from a background thread, Enqueue a task for a different thread and Schedule a task for a specified time.
What is a Pending Intent:
A Pending Intent is an action to require in the future. It allows you to pass a future Intent to a different application and permit that application to execute the Intent.
What is SQLite:
SQLite is an embedded SQL database engine with multiple tables, indices, triggers, and views, contained in a single disk file. SQLite modifies data directly to ordinary disk files.
What is a Toast in Android:
Android Toast displays information for a short period of time that contains a message to be displayed quickly and disappears after some time. It also used to show notifications for a particular interval of time at the bottom of the screen by default.
Shared Preferences in Android:
Shared Preferences persist data across user sessions that should be remembered across sessions, such as user’s preferred settings or their game score, even if the app is killed and restarted, or the device is rebooted.
What is Android Jetpack:
Android Jetpack is a set of Android components, tools, and guidance inspired by the backward compatibility of the Support Library and Android Architecture Components that are platform-independent, allowing your app to run on multiple Android platforms.
What is a Bound Service in Android:
The bound service is a server in a client-server interface that allows components such as activities to bind to the service, send requests, receive responses, and perform inter-process communication (IPC).
What do you mean by a DialogFragment:
A DialogFragment is a fragment that floats on top of the current activity window and displays a modal window. An instance of DialogFragment can be used to display an existing Dialog implementation dialog or a custom view hierarchy by using the Dialog class that is the base class for implementing a dialog.
What is presenter in MVP:
The Presenter acts as a mediator between model and view. All your presentation logic belongs to the presenter which is responsible for querying the model and updating the view, reacting to user interactions, and updating the model.
Bitmap pooling in Android:
You can avoid continuous allocation and deallocation of memory in your application by using the Bitmap pool, you can reduce GC overhead, which results in a smooth-running application.
Recycler View in Android:
Android Recycler View is an enhanced version of ListView. It has improved performance and other benefits. You can use RecyclerView and CardView together, which creates both lists and grids very easily.
View Holder Pattern:
A view holder design pattern is used to speed up the rendering of your ListView to make it work smoothly, findViewById is quite expensive when used each time a list item is rendered, it must traverse your layout hierarchy.
WebView in Android:
Android WebView is a system component that allows Android apps to display web content. It is pre-installed on your device and should be kept up to date to ensure you have the latest security updates and other bug fixes.
What is Android Runtime?
Android Runtime (ART) is an application used by the Android Operating System as a runtime environment. It has now replaced Dalvik, which is a discontinued Virtual Machine (VM). Android Runtime (ART) translates the bytecode of the application into native instructions, which are carried out by the device’s runtime environment.
What is Reflection in Android?
Reflection is an API that is used to verify or modify the behavior of methods, classes and interfaces at runtime. The required classes for reflection are present in java.lang.reflect package.
What is a content provider in android?
Content providers are used to share information between android applications.A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.
What is an Adapter in android?
The Adapter is used to create child views to represent the parent view items. Adapter in android are basically bridge between UI components and the data source that fill data into UI Component.
Name the dialog box which are supported by android?
AlertDialog
ProgressDialog
DatePickerDialog
TimePickerDialog
How is nine-patch image different from a regular bitmap?
It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.
What is fragment in Android?
A fragment is usually used as part of an activity’s user interface and contributes its own layout to the activity. To provide a layout for a fragment, you must implement the onCreateView() callback method, which the Android system calls when it’s time for the fragment to draw its layout.
Describe three common use cases for using an Intent in Android.
(a). To start an activity : We can start a new instance of an Activity by passing an Intent to startActivity() method.
(b). To start a service : We can start a service to perform a one-time operation (such as download a file) by passing an Intent to startService().
(c). To deliver a broadcast : We can deliver a broadcast to other apps by passing an Intent to sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().
What is ANR?
ANR stands for Application Not Responding. It is a dialog box that appears if the application is no longer responding
What is AAPT?
AAPT is an acronym for android asset packaging tool. It handles the packaging process.
What is DDMS?
DDMS stands for Dalvik Debug Monitor Server. It gives the wide array of debugging features:
1. Port forwarding services
2. Screen capture
3. Thread and heap information
4. Network traffic tracking
5. Location data spoofing.
Comments
Post a Comment