Android - Basics of Operating System


Android SDK tools compile the code and resources into an android package also know as .apk file. This is the file which is used by android to install the application.

Each application on android devices lives in its own security  sandbox. Android operating system is a multi-user linux system in which each android application is a different user. Each application is identified by a unique id.

Every android application runs in its own process. Each process has its own virtual machine so an application runs in isolation from other applications.

Android application has 4 main components.

  1. Activity.
  2. Broadcast Receiver.
  3. Content Providers.
  4. Services.

They are the piece of code which has certain callback methods. They have a well defined life cycle methods. Activity is what you see on screen. Service helps to perform an operation in background. Content providers facilitates data for your android application. Broadcast Receiver helps to listen system wide broadcast announcements.

Android Manifest File

  • Application must declare each component used by it in AndroidManifest.xml file. Then only android system will allow the application to run that component.
  • You should also declare any permission required by your file. For example : Internet access, Hardware acces, Camera, Bluetooth Access.
  • You also need to declare the minimum API required by your application in android manifest file.
<uses-permission android:name="android.permission.INTERNET" />

Whenever application runs in android operating system by default it runs in the main thread. All the application components like activity, broadcast-receiver runs in the same thread and process. We can make components to run in different threads by using background threads.

Any slow blocking operation should be run in another process or thread so that it does not affect the Main thread which is also know as user interface thread.

We should always access the user interface items from the main thread only. So when using background threading make sure to keep it in your mind.

We can create multiple threads using AsynchTask and Handlers. By doing so we prevent Main/UI thread from getting blocked.