Understanding Processes

So far, we have been treating our activity like it is our entire application. Soon, we will start to get into more complex scenarios, involving multiple activities and other types of components, like services and content providers.

But, before we get into a lot of that, it is useful to understand how all of this ties into the actual OS itself. Android is based on Linux, and Linux applications run in OS processes. Understanding a bit about how Android and Linux processes inter-relate will be useful in understanding how our mixed bag of components work within these processes.

And, along the way, we will answer nagging questions like, “what is that Bundle thing that we are passed in onCreate() that we have been ignoring?”.

When Processes Are Created

A user installs your app, goes to their launcher’s app drawer, and taps on an icon representing your activity. Your activity dutifully appears on the screen.

At this point, we know that we have a process for our app, because it is running.

Frequently, the trigger for Android to fork a process for you is that the user tapped on your launcher icon and launched your activity. However, your process might already exist for other reasons. In that case, by default, Android will reuse your existing process, and have it display your activity. By default, your app will have at most one process.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.