Reputation: 3594
I was looking into this topic as I wanted to learn more. So I found out the following stuff:
The Android OS gives importance to our app based on the following factors:
onResume()
when we are interacting with the UI of the an app. (Highest Importance)onPause()
when some dialog comes above an app which we are currently using.Activity
, Service
, Content Provider
or BroadCast Receiver
) in the process. (Lowest Importance - will be the first one to be removed from memory)I have to give a seminar for this topic, it goes without saying that I need to give example for each of the above 5 cases.
I am having a hard time for coming up with an example for Background Process.
So for an app to be categorized as Background Process by the Android OS then there should not be any interaction with the user and a thread should be running.
The thing is I am not able to come up with a proper convincing example for Background Process.
Can some one help me out ?
Edit (Only for those people who think this topic is not related in any way to memory management)
This is how Android OS assigns memory to app (if there is not enough memory) by removing app based on above categories, I believe it comes under memory management.
Upvotes: 4
Views: 380
Reputation: 200130
As explained in this Android blog post, a background process:
At this point, the process is considered a background process. It has nothing to do with whether a thread is running or not - the process could certainly not be doing anything at all. In fact, the only difference between an empty process and background process is the previously active activity. In both cases, these processes are kept around primarily for caching purposes and can be killed at anytime.
Upvotes: 0
Reputation: 193
Android Async task is an example of background process. It is also synchronized with the main UI thread.
doInBackground()
method of async task does the background processing (no UI interaction) but its methods like onPreExecute()
and onPostExecute()
can interact with the UI.
Example: You want download an image, initialize the image view in onPreExcute()
, download processing goes to doInBackground()
method and display the downloaded image on image view in onPostExecute()
.
Upvotes: 1