Listly by edureka.co
The demand for Android developers is on a meteoric rise and the time is right to break into a career in Android development. To help you get started, here is a list of frequently asked Android interview questions to help you ace the Android interviews that come your way.
The latest version is Android 9.0- Android Pie released in August, 2018. Android is a mobile operating system developed by Google. It is based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. Every other Android version has been named after either sweet or desserts. The above table represents the Android name, version and the year of release.
An Activity is the screen representation of an application in Android.
It serves as an entry point for the user’s interaction. Each activity has a layout file where you can place your UI. An application can have different activities. For example, facebook start page where you enter your email/phone and password to login acts as an activity.
Below are the two methods which almost all subclasses of Activity will implement:
onCreate(Bundle): It is a method where your initialization is done. Under this, you will callsetContentView(int) with a layout resource which defines your UI. Also, you can retrieve the widgets in that UI by using findViewById(Int). These are required to interact programmatically.
onPause(): It is a method which deals with the user whenever it leaves the activity. So any changes made by the user should be commited which is done by the ContentProvider that holds the data.
An activity is implemented as a subclass of Activity class as follows:
public class MainActivity extends Activity {
}
Google has changed the lives of everyone by launching a product that improves the mobile experience for everyone. Android helps in understanding your tastes and needs, by giving various features such as having wallpapers, themes, and launchers which completely change the look of your device’s interface.
Android has plenty of features. Some of the features are listed below:
Android - Android Interview Questions - EdurekaOpen-source
Customizable operating System
Variety of apps can be developed.
Reduces overall complexity
Supports messaging services, web browser, storage(SQLite), connectivity,media and many more.
User navigates between different screen or app, it goes through different states in their lifecycle. So an activity lifecycle consists of 7 different methods of android.app.Activity class i.e :
onCreate() : In this state, the activity is created.
onStart(): This callback method is called when the activity becomes visible to the user.
onResume(): The activity is in the foreground and the user can interact with it.
onPause(): Activity is partially obscured by another activity. Other activity that’s in the foreground is semi-transparent.
onStop(): The activity is completely hidden and not visible to the user.
onDestroy(): Activity is destroyed and removed from the memory.
An Intent is an “intention” to do an action. An intent is a messaging object you can use to request an action from another app component.
Methods are used to deliver intents to different components:
context.startActivity() – To start an activity
context.startService() – To start a service
context.sendBroadcast() – To deliver a broadcast
Types of Intent:
Implicit Intent: Implicit intent is when the target component is not defined in the intent and the android system has to evaluate the registered components based on the intent data.
Explicit Intent: Explicit intent is when an application defines the target component directly in the intent.
The difference between them are as follows:
*File *is a block of arbitrary information or resources for storing information. It can be any file type.
*Class *is a compiled from of .Java file which Android uses to produce an executable apk.
*Activity *is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type but just a class that can be extended in Android to load UI elements on view.
Syntax:
Toast.makeText(ProjectActivity.this, "Your message here", Toast.LENGTH_LONG).show();
ANR stands for ‘Application Not Responding’. This dialogue is displayed if the main thread in the application has been unresponsive for a long time and in the following conditions:
When a broadcast receiver is not done executing within 10 seconds.
Following measures can be taken to avoid ANR:
To avoid ANR, an app should perform a lengthy database or networking operations in separate threads.
WebView is a view that display web pages inside your application. According to Android, “this class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more. In order to add WebView to your application, you have to add element to your XML layout file.
Manifest file plays an integral role as it provides the essential information about your app to the Android system, which the system must have before it can run any of the app’s code. Manifest file performs various tasks such as:
Structure of a manifest file: The structure of a manifest file consists of various elements such as action, activity, activity-alias and many more. Refer to the below screenshot which shows the general structure of the manifest file.
version="1.0" encoding="utf-8"?
cmanifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aayushi.myapplication">
To keep reading more questions like these you can click here