Posts

Showing posts with the label Android interview questions and answers

Battery optimization based Android interview questions and answers

What is doze mode? Device enters doze mode if, an user leaves it unplugged and stationary for a period of time, with the screen off. In doze mode network access and and CPU-intensive services are restricted. Periodically, the system exits Doze for a brief time to let apps complete their deferred activities. Systems exits doze mode if user wakes the device by moving it, turning on the screen, or connecting a charger. Reference http://developer.android.com/training/monitoring-device-state/doze-standby.html What is App Standby? An application goes to App Standby mode if the user does not touch the app for certain period of time and none of the following conditions happened: you explicitly launch the app The app has a process currently in the foreground The app produces a notification When in standby mode, network access and background sync jobs are restricted. When user plugs the device into a power supply, system releases apps from standby mode. Reference http://developer.android.com/tra...

Dependency Injection based Android interview questions and answers

WHAT IS DEPENDENCY INJECTION? DO YOU USE ANY DI LIBRARY IN YOUR PROJECT? CAN YOU NAME A FEW OF THEM, AND WHY ONE IS BETTER THAN OTHERS? Dependency Injection is a design pattern to implement inversion of control, and to resolve dependencies. Dependency Injection (DI) eliminates boilerplate code (for example, by removing listener) and provides a much cleaner and effective code. There are a few DI libraries used in Android development: -Dagger -ButterKnife -RoboGuice ButterKnife and Dagger do not use reflection, but rather compile time annotations. They are therefore faster to develop with. What is dependency injection? Is a pattern for resolving dependency. It is an implementation of dependency inversion principle (DIP). Some of the libraries to enable dependency injection for are, AndroidAnnotations Butter Knife Dagger Dagger2 RoboGuice Dagger Component Vs Subcomponent Component dependencies — Use this when you want to keep two components independent. Subcomponents — Use this when y...

Thirty party libraries based Android interview questions and answers

Social media library: How many data can we get from Facebook API? Ans: Using graph library and Profile class, we can get all the information of a user. ex Name, first name, last name, profile image, middle name Image library: Difference between Picasso and glide Library in Android? Ans: Picasso library can only load an image, where glide can also load gif format. Which 3rd party library you have used in Android? Ans: Retrofit, Picasso, Glide, volly.

TextView and EditText based Android interview questions and answers

How to make a TextView to be editable? A) Either set its attribute editable =’true’ or Use EditText class instead of TextView class

Sensor based Android interview questions and answers

What can sensors measure? A) Relative humidity Pressure Magnetic field Steps taken Proximity The rate of ratation of the device on x,y,z axes What is a Physical Sensor? A) Sensors that pieces of hardware that are physically present on the device. Know as Hardware Sensors. What are Synthetic sensors? A) Sensors that are not physicall present on the device. They are derived from one or more sensors What is Raw? A) Values directly given by the sensor without any correction logic. Accelerometers, proximity sensors, light sensors, 133) What is Calibrated? A) Values from sensors that are corrected by the operating system 134) What is Fused? A) Sensors that gets values from two or more sensors. These values are combined to one value 135) What is SensorManager? A) Provides access for your app to the sensors. 136) What is Continuous? A) That report mode when sensor events are generated at a constant rate defined by the sampling peroid 137) What is On change? A) That report mode when sensor even...

NDK based Android interview questions and answers

What is Android NDK? A) A toolset that allows you to implement parts of your app using native-code languages What is the NDK and why is it useful?   -   Learn from here   and   here   and   here What is renderscript?   -   Learn from here

Testing based Android interview questions and answers

What is Test Module? A) Module that contains the source code to test application projects and is built into test application that run on a device What is JUnit? A) A unit testing framework for the Java programming language What is TDD (Test-driven development)? A) A software development process that relies on the repetition of a very short development cycle: first an automated test case is written that defines a desired improvement of new function What is Test case? A) Set of conditions under which a tester will determine whether an application, software system or one of features is working as was originally established for it to do What is the difference between unit testing and instrumentation testing? Unit testing: All unit tests bypass the Android system and run straight on the developer machine. Unit tests cannot use much of the Android SDK Unit tests run quickly Unit tests are placed inside the “test” folder Instrumentation testing: Test code and production code combined is runni...

Logcat based Android interview questions and answers

What is logging (Logcat)? A) The logging (Logcat) system provides a mechanism for collecting and viewing system debug output. How many different  logcat  types are there? A) 5 What are the names of the specific  logcats ? A) Verbose, Debug, Info, Warn and Error Logging methods require two strings, what does each string represent? A) The first string (Tag) identifies where the log is coming from and the second is the specific log message.

CustomView based Android interview questions and answers

1) Design one custom view for displaying TextView in UI with a attributes tribute like Title and Colour. When we need to create any custom view in Android, we will extend our class from the View parent class. In this scenario, as we need to create a custom Text view so we will create a subclass of TextView class.  And then we can our Custom textview in a layout.xml file. For example please follow below code where I am trying to create Custom TextView CustomTextView extends TextView { private String title;     private boolean color; title = tarry.getString(R.styleable.CustomTextView_settitle);             if(title == null)             setText("Custom Message");             else                 setText("Welcome to the Class"); color = tarry.getBoolean(R.styleable. CustomTextView _setColor, false);             if(colo...

Menu based Android interview questions and answersd

1) Suppose if I want to change menu Item at runtime what approach I should follow? Menu Item is part of the menu.xml file. When we want to add a menu in-out activity we need to method OnCreateOptionMenu(Menu menu). But If you want to add any Menu Item at run time then the system calls your activity’s onPrepareOptionsMenu() method. this method passes currently exist menu object to modify the menu item. Please follow the below code for more detail: @Override public boolean onPrepareOptionsMenu(Menu menu) {     if(Build.VERSION.SDK_INT > 11) {         invalidateOptionsMenu();         menu.findItem(R.id.option1).setVisible(false);         menu.findItem(R.id.option2).setVisible(true);     }     return super.onPrepareOptionsMenu(menu); A

Notification based Android interview questions and answers

1) What is the use of Notification Chanel and how to create it? Notification Channels. Notification Channels allow us to separate notifications into different groups/categories. Basically, Notification Channel is designed for User. They can get full control of what they want to be notified about. If they don’t want any notification they can specifically turn off notifications for a certain channel. They can also specify importance as well as the preferred sound for a particular category of notifications and determine whether or not to override Do not disturb The NotificationChannel constructor requires us to specify the channel_id and channel_name strings. The Importance argument is an int which specifies the level of interruption by the notification. val  MessagesChannel = NotificationChannel(                    MESSAGES_CHANNEL_ID,                    context.getString(R.string_chan...

Architecture Components based Android interview questions and answers

Image
What is Android Jetpack and why to use this?  -  Learn from here What are Android Architecture Components?  -  Learn from here ViewModel What is ViewModel? Viewmodel is a Jetpack component, The class is designed to store and Manage the UI related data. To handle data upon Lifecycle changes of activity/application, Like Screen orientation changes.   How to create ViewModel class in Android To work with ViewModel we need to create a class that should be extends from ViewModel class.   How to instantiate ViewModel Class? We can instantiate ViewModel class by two way With default constructor(new key word in java) With ViewModelProvider class Class MyViewModel() extends ViewModel{ }     1=> MyViewModel obj=new MyViewModel()     1=> MyViewModel obj= ViewModelProvider(this).get(MyViewModel.class)      Note:  Always use ViewModelProvider to create ViewModel objects rather than directly instantiating an instanc...

Networking based Android interview questions and answers

Which method to open Http connection to an Uri? A) url. openConnection( ) To get data from Webserver to Android application, which of the following class you need to use to establish connection? A) HttpURLConnection 02 Android JSON Parsing What is JSON? A) JSON is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML What is the name of Android class do we need to use to build up an JSON object? A) JSONObject Assume that we have an Android object named stored in reader variable, and inside it has a child object named? A) JSONObject mainObj = reader.getJSONObject("main"); What is JsonParsing? Ans: JSON stands for Javascript object notation, a format for data exchange from the server. In Android, when we work with the online database, we need to convert table data into JSON data, and to manipulate those data Android provides a different way for JSON Parsing. HTTP Url ...

SQLite based Android interview questions and answers

1) What are joins that are not supported by SQLite? Answer: Right outer join and full outer joins 2) What are SQLite and its methods? Answer: SQLite is a relational open source database which comes inbuilt in android devices which enables you to store, retrieve, manipulate and delete data. Using SQLite android application can run in offline mode also. Sqlite is implemented in our project by extending the class with SqliteOpenHelper class which overrides 2 methods i.e; 1.oncreate() -Where the database is created along with its version. 2.onUpgrade() -It is supporting function of onCreate() when the version has updated the changes in a database will be performed in an on upgrade method without disturbing the existing one 3) What is the limit of data storage in sqlite? Answer: Maximum data SQLite can store depends on the storage space of your device. SQLite database save data in which storage? A) Internal storage There are five different methods to store persistent data. They are...

Manage Task based Android interview questions

1) What are "launch modes"? 2) Suppose there are two activities in a single android application with launch modes as 'singleInstance'. Assume an example below.I am navigating from activity A -> B(launchMode="singleInstance"). Now from activity B -> C. Finally, I navigate from activity C -> D(launchMode="singleInstance").Now we know the instance of activity B will be created in a different task, and A & C will be in different tasks.Now, my question is, in which task instance of activity D would be placed. Will it be with activity B, or some other task would be created for activity D? Launch mode is an instruction for Android OS which specifies how the activity should be launched. It instructs how any new activity should be associated with the current task. So in your scenario When using launchMode="singleInstance", there are two things that we need to remember: The Activity will always be created in a new task All Activities l...

Memory optimization based Android interview questions and answers

Memory Leaks 1) How do you find memory leaks in the mobile app on the Android platform? Answer:  Android Studio is using Android Device Manager (ADM), this ADM is used to detect the memory leaks in the Android platform. When you open ADM in the Android Studio then on the left-hand side of the ADM, you will find your device or emulator in which a heap sign will be displayed. When you are running any mobile app then you will see the heap size, memory analysis and other statistics displayed on it. CAN YOU PROVIDE SOME IDEAS ON HOW TO PREVENT MEMORY LEAKS INU YOUR APP? There are many strategies that can be applied. Here there is just a small set of ideas. -Is better to use an Application Context rather than an Activity Context , since Activities are more likely to be leaked. -Is generally good to avoid having long-lived references to Activities. -Is better to avoid non-static inner classes in Activities unless we control their lifecycle. Is better to use static inner classes with weak ...

Dialog based Android interview questions and answers

1) Which are the dialog boxes supported by the Android platform? Answer:   Android supports six types of dialog boxes: AlertDialog : It has a maximum of 3 buttons and sometimes AlertDialog includes checkboxes and Radio buttons to select the element. ProgressDialog : It displays the progress bar or wheels. TimePickerDialog : Using this dialog box, a user selects the Time. DatePickerDialog : Using this dialog box, a user selects the Date BottomSheetDialog Finger print Dialog

Design Patterns based Android interview questions and answers

Image
1.Creational Design Pattern Factory Pattern Abstract Factory Pattern Singleton Pattern Prototype Pattern Builder Pattern. What is singleton pattern? Singleton is a most commonly used design pattern and is used when we want one and only one instance of a class per JVM. Classes developed to perform business logic is good example of Singleton class. Name one singleton class in Java? Runtime How we can create a class singleton? To make any class singleton, we need to consider or implement following- Private or protected constructor- We need to make the constructor of a class private so that no one from outer world can call a “new”. Create a private static instance of the class. Create a public static method which will return the instance created. Explain early and lazy loading of singleton class? We can have an early and lazy loading of a singleton class. In case of early loading, an object of singleton class is instantiated while loading of  a class where as in case of lazy loadi...