Android Internals #1: How Android Starts Your Main Activity.

Martin Ombura Jr.
Martin Ombura Jr.
6 min readDec 16, 2017

--

I was recently doing some research on the Java main method, and how it serves as the entry point for any Java application. This got me thinking, what about Android applications? do they have a main method? How are they booted? What happens beneath the scenes before our Activity’s onCreate()
method is called. Michael Bailey gave really insightful talk on how the Main Thread works, some of what I’ll cover is a quick glance over his talk plus some extra information from the Android Open Source Project (AOSP).

This article will look to:
1. Show the process from app click to Activity launch.
2. Locate your app’s main method and find out how the main thread gets its designation.
3. Showcase the role the the Looper & Handler have in passing messages that eventually lead to your Activity’s creation.

What happens when an app is launched

When any application is launched, a lot happens behind the scenes on a kernel level e.g Bootstrapping the Zygote, loading classes into the JVM, and for the JVM to locate the static void main(String args[]) method and invoke it. In the case of Android, the JVM locates the main method in the ActivityThread. It then invokes the method, at…

--

--