1.What do you mean by Android AsyncTask(Asynchronous task) ?
An asynchronous task is used to perform an operation into the background thread and update the main thread after completing the process or result.
When we download any content from the website or internet then we see the downloading operations are performed into the background.
After completing the process or download,we see the result on the main thread.
# Methods of Asynchronous task
1.onPreExecute( ) 2.doInBackground( ) 3.onProgressUpdate( ) 4.onPostExecute()
#There are three generic parameters used in AsyncTask.
1.Params 2.Progress 3.Result
2.What is the difference between add( ) and replace( ) method in fragments ?
add( ): is used to retain existing fragment and adds new fragment that means existing fragment will be in active state and it won’t be in ‘pause’ state hence when a back button is pressed onCreateView( ) will be not called for the existing fragment(previous fragment).
replace( ): is used to replace the existing fragment and adds a new fragment.That means when we press back button the fragment gets replaced and onCreateView( ) method will be called.
3.What do by means of View Model and Live Data ?
View Model class is used to store and manage UI(User Interface) related data in a an android life-cycle
It is also used to survive the data on configuration change such as screen rotation.
Live Data is an observable data holder class.It notify the observer when any updates are made on the UI(User Interface).
There are the different advantages of Live Data
1.It ensures your UI matches your data state
2.No Memory leaks
3.No crashes due to stopped activities
4.Always up to date data
4.How many types of Launch mode in an android ?
There are four types of launch mode in an android
5.What do you mean by Activity and Application Context ?
Activity context refers to the instance of the activity within the activity -lifecycle.
Activity context refers to the instance of the activity within the application -life-cycle.
6.What do you mean by DVM(Dalvik virtual machine) ?
Android uses DVM(Dalvik virtual machine) rather than JVM.All the java classes are converted into single. dex file by Dex compiler and this .dex file runs on the Dalvik virtual machine.
7.Suppose you have two activities A and B.When you move from activity A to B.Which activity -life method will be called ?
## When launch activity A
## When Move from activity A to B by using startActivity(intent)
Activity A -onPause( )
Activity B- onCreate( )
Activity A-onStop( )
## When you press back button from activity B then activity-lifecycle method will be called
Activity B-onPause( )
Activity A -onRestart( )
Activity B- onStop( )
8.Write down Activity-Lifecycle and Fragment Life-cycle ?
9.How can you data from Activity to Fragment using a bundle ?
##Write below code inside the button click listener
Bundle b=new Bundle( );
FragmentName fragment=new FragmentName( );
##Write the below code inside the onCreateView( ) method.
10.What do you mean by Services in an android ?
Service is an android component which runs into the background to perform long-running operation.It does not contain any UI(User Interface )
There are three types of services is an android
Thanks and Regards