1. What is the architecture of Android?
2. How many ways are there to create a bound service?
3. What are the steps to create a Bound service using AIDL?
SHOW/HIDE ANSWER
Three,
- Create the .aidl file : defines the programming interface with method signatures
- Implement the interface : extend the Stub class and implement the methods
- Expose the interface to clients : Implement a Service and override onBind() to return your implementation of the Stub class
4. Will calling finish() on an Activity calls all the usual activity life cycle method?
SHOW/HIDE ANSWER
Yes, except if you are calling it from onCreate, in which case onDestroy() will be immediately called without any of the rest of the activity lifecycle (onStart(), onResume(), onPause(), etc) executing.
5. Should base Activity class's onCreate should be called from your Activity implementation?
6. What is the activity life cycle?
SHOW/HIDE ANSWER
http://developer.android.com/guide/components/activities.html
- onCreate : System calls this method while creating the activity
- onStart : Called just before the activity becomes visible
- onResume : Called just before the activity starts interacting with the user, such as receiving the events
- onPause : Called when the system is about to start resuming another activity
- onStop : Called when the activity is no longer visible to the user
- onRestart : Called after the activity has been stopped, just prior to it being started again
- onDestroy : Called before the activity is destroyed
http://developer.android.com/guide/components/activities.html
7. What is the Fragment life cycle?
SHOW/HIDE ANSWER
Reference
http://developer.android.com/guide/components/fragments.html
http://developer.android.com/reference/android/app/Fragment.html
- onAttach: called once the fragment is associated with its activity.
- onCreate: called to do initial creation of the fragment.
- onCreateView: creates and returns the view hierarchy associated with the fragment.
- onActivityCreated: tells the fragment that its activity has completed its own Activity.onCreate().
- onViewStateRestored: tells the fragment that all of the saved state of its view hierarchy has been restored.
- onStart: makes the fragment visible to the user (based on its containing activity being started).
- onResume: makes the fragment begin interacting with the user (based on its containing activity being resumed).
- onPause: fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.
- onStop: fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.
- onDestroyView: allows the fragment to clean up resources associated with its View.
- onDestroy: called to do final cleanup of the fragment's state.
- onDetach: called immediately prior to the fragment no longer being associated with its activity.
Reference
http://developer.android.com/guide/components/fragments.html
http://developer.android.com/reference/android/app/Fragment.html
8. How to programmatically add fragment to an existing ViewGroup?
SHOW/HIDE ANSWER
http://developer.android.com/guide/components/fragments.html#Adding
// Create new fragment and transaction Fragment newFragment = new ExampleFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit();Reference
http://developer.android.com/guide/components/fragments.html#Adding
9. What are the steps to implement Loader?
SHOW/HIDE ANSWER
http://developer.android.com/guide/components/loaders.html
- Initialize the LoadManager or restart it with initLoader or restartLoader respectively
- Implement the Loader implementation class
- Override the LoaderManager.LoaderCallbacks
- Return your Loader implementation from onCreateLoader
- Use the data from onLoadFinished
http://developer.android.com/guide/components/loaders.html
10. What are the two types on Intents?
SHOW/HIDE ANSWER
http://developer.android.com/guide/components/intents-filters.html#Types
- Explicit intents specify the component to start by name (the fully-qualified class name)
- Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.
http://developer.android.com/guide/components/intents-filters.html#Types
11. What is a content provider?
12. What are the advantages of AsyncTaskLoader over AsyncTask?
SHOW/HIDE ANSWER
- AsyncTaskLoader can an handle Activity configuration changes more easily
- Closer relationship with Activity/Fragment life-cycle
13. How many threads are there to service AsyncTask jobs?
14. What are the levels in the importance hierarchy for an Android process?
SHOW/HIDE ANSWER
There are 5 of them and they are,
http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
- Foreground process
- Visible process
- Service process
- Background process
- Empty process
http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
15. What is reactive programming?
SHOW/HIDE ANSWER
It is an emerging discipline that combines asynchronous and event-based systems. RxAndroid provides support for reactive programming for Android.
References
https://github.com/ReactiveX/RxAndroid
http://reactivex.io/tutorials.html
https://www.youtube.com/watch?v=JCLZ55M2gVo
References
https://github.com/ReactiveX/RxAndroid
http://reactivex.io/tutorials.html
https://www.youtube.com/watch?v=JCLZ55M2gVo
16. How to cancel an AsyncTask?
SHOW/HIDE ANSWER
First call the method cancel on the AsyncTask. Now it will not cause the AsyncTask to cancel by interrupting the background thread.
But it will cause isCancelled() to return true. You should always check the return value of isCancelled() periodically from doInBackground(Object[]), if possible (inside a loop for instance.)
Reference
http://developer.android.com/reference/android/os/AsyncTask.html
http://developer.android.com/reference/android/os/AsyncTask.html
17. What are the two types of services?
SHOW/HIDE ANSWER
http://developer.android.com/guide/components/services.html
- Started : If is started by calling startService().
- Bounded : If is started by calling bindService().
http://developer.android.com/guide/components/services.html
18. In which thread does a Started or Bounded service run?
19. Can a service run in the foreground?
20. What is Retrolambda?
SHOW/HIDE ANSWER
Retrolambda hepls us in using Java 8 lambda expressions on Java 7, 6 or 5
Reference
https://github.com/orfjackal/retrolambda
http://blog.trsquarelab.com/2016/01/lambda-support-in-android-with-retro.html
Reference
https://github.com/orfjackal/retrolambda
http://blog.trsquarelab.com/2016/01/lambda-support-in-android-with-retro.html
Great set of questions!
ReplyDeleteThanks
ReplyDelete