Top 10 important Android Interview Question with Answer for Experience Android Developer?


Hello Friends today i am sharing some advance android interview question with answers please read all questions it can help to crack interview.

if you want to learn about top most android basic interview question and answer please click blow link it can help to understand about basic android question.
https://android4point.blogspot.in/2016/12/top-10-android-interview-question-and.html

1.What is Asynctask class and its methods in android?

What is AsyncTask class?

AsyncTask is a android class which is allows to run instructions in the background and to synchronize again with the main thread.

when started AsyncTask class

AsyncTask is started when we called execute() method. This execute() method calls the doInBackground() and the onPostExecute() method.

What is use of AsyncTask?

This AsyncTask class allows to perform background operations and publish results on the UI thread without manipulate threads or handlers.

you must extend doInBackground() method inside AsyncTask class(its necessary).

There are 4 methods you will need to implement in AsyncTask class:

1. onPreExecute() – called on the UI thread before the thread starts running. This method is usually  used to setup the task, for example by displaying a progress bar.

2. doInBackground(Params…) – this is the method that runs on the background thread. In this method you should put all the code you want the application to perform in background. Referring to our Simple RSS Aplication, you would put here the code that downloads the XML feed and does the parsing. The doInBackground() is called immediately after onPreExecute(). When it finishes, it sends the result to the onPostExecute().

3. onProgressUpdate() – called when you invoke publishProgress() in the doInBackground().

4. onPostExecute(Result) – called on the UI thread after the background thread finishes. It takes as parameter the result received from doInBackground().

2.What is ANR  in Android and How can the ANR be prevented?

What is ANR?

First thing we know that ANR means Application Not Responding.
ANR will occur when you are running long time UI thread.

How to avoid ANR?

To avoid ANR we can run your lengthy task in separate thread,Handlers,AsyncTask etc. instead of UI thread(Main Thread).


3. Sqlite in Android?

Android OS provides many ways to store data. SQLite is one of the best way to storing user data.because the SQLite is a light weight database which comes with Android OS.In android os SQLite is an open-source relational database i.e. used to perform database operations on android devices such as storing, manipulating or retrieving persistent data from the database.

if you want to know more about Sqlite and demo example please click blow link.
https://goo.gl/YaorXB

4. What is DDMS? Describe some of its capabilities.

Now a time we are using Android Studio which is provide debugging tool called the Dalvik Debug Monitor Server (DDMS), which provides so many facility for developer like screen capture on the device, thread and heap information on the device,port-forwarding services, logcat, process etc.

How to run(Open) DDMS in android?

Open Android studio and click on Tools>Android>Android device Monitor.

How to DDMS works?


When we start DDMS it connects to adb (or currently running android devices). When a device is connected, a VM monitoring service is created between adb and DDMS, which notifies DDMS when a VM on the device is started or terminated.

5. What is difference between Serializable and Parcelable ? Which is best approach in Android?

serialization 

android developing we used java serialization as a data transfer mechanism between activities and it is a marker interface which implies the user cannot marshal the data according to their requirements.
This helps identify the Java objects member and behavior, but also ends up creating a lot of garbage objects. Due to this, the Serialization process is slow in comparison to Parcelable

Parcelable

Parcelable is an Android specific interface where you implement the serialization yourself.
In Parcelable, developers write custom code for marshaling and unmarshaling so it creates less garbage objects in comparison to Serialization.

6. What are different data storage options are available in Android?

Android has following options for you to save persistent data.We can choose depend on own specific needs, such as whether data should be private to over application or accessible to other application and also depend on how much space required by data.
The data storage options are the following.
  •     Shared Preferences
  •     Internal Storage
  •     External Storage
  •     SQLite Databases
  •     Network connection
if you want to know more about this topic please click blow link
https://goo.gl/7DCTIR

7. Is it possible to add a fragment without using a user interface?

Ans. Yes, it is possible.
when we 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.

8. What do you  know about Sticky Intent?

A Sticky Intent is a like broadcast from sendStickyBroadcast() method.


9. What is an action?

An action is a Intent sender which is want to get as a response.we are use action tag inside the manifest.xml.file with the help of inside Intent filter.


10. what is Handler in android?

Handler is like a thread but Handler allow to user interference in android OS like update the value of Textview from other thread, it is necessary that UI objects could only be updated in UI Thread. Also, when you just want to run some light code later(like delay for some ms) you can use Handler because it's lighter and faster.

The Handler is associated with the application's main thread. it handles and schedules messages and runnables sent from background threads to the app main thread.

11. Different between Handler and thread?

11.1 When we have to use Thread in android:

1) First thing is that we have to use thread when we execute long running process that would block the UI from updating. 

2) Second thing is when we lock the UI thread for more than 5 seconds then the user will be prompted for  "kill or wait" by the OS.

3)When you're doing a heavy work like network communication, or decoding large bitmap files, a new thread is preferred. 

11.2 When we have to use Handlers in android:

1) I recommended to you use for Handler when you just want to run some light code like mili of second because Handler is lighter and faster.
when you just want to run some light code later(like delay for 300ms) you can use Handler because it's lighter and faster.

2) We can use also Handlers when we want to bound to threads that allow you to communicate with the UI thread (update the UI).