Android Basics - JamesDansie/data-structures-and-algorithms GitHub Wiki

Android Basics

Author: James Dansie

Android apps can be written in Kotlin, Java or C++. The adroid SDK (software development kit) will compile the code into an APK (android package) with a .apk extension. One apk has all the content of the app. Each Android app is its own Linux user, and only the OS knows the app id. This means each app is an isolated environment, which makes them secure. Each app is only given the permissions it needs to run, and no more. An app can request extra permissions (camera, location, etc.), but it has to be explicitly given by the user. It is possible for apps to share the same Linux user ID, so they can share system resources, VM, and to access each other's files.

App components can be thought of as app entry points. There are four different types;

  1. Activities - implements an Activity superclass. It keeps track of what the user is currently using, and was previously using so they can return to it if needed. A good example is a picture app, that has an email activity. So the user can use the email activity to share the photo, but can then return to the picture app.
  2. Services - a service is a background app that lets everything just keep running. For example it could play music in the background, or ping the network for data while letting everything run. A service app implements a Service superclass. A started service receives a higher priority, so the OS won't shut it down. A Bound service is a lower priority, so the OS can start it up or shut it down more easily.
  3. Broadcast receivers - These are components that enable the OS to deliver events to the app outside of a regular flow (even if the app is off). Most of the these events originate with the OS (for example; low battery, the screen powered off, etc.) This is a subclass of BroadcastReceiver and each broadcast is an Intent object.
  4. Content providers - A content provider is a shared form persistent data (SQLite database, on the web or something else). For example Contacts is a shared resource that any app can access or modify if given permission.

References

  1. https://developer.android.com/guide/components/fundamentals