The first thing that is important to understand as a developer is what really happens behind the scene when a user taps on an app icon. How does a developer gain access to the entry point of the application. For this post I will focus on the flow only. If you need to understand how to create your app then follow the simple instructions in this tutorial - Building your first App.
- Identify MAIN activity
When an app launches, the Android OS first looks into AndroidManifest.xml file to identify the MAIN activity. It looks for an activity tag containing intent-filter with name android.intent.action.MAIN. - Start the APP
Once the MAIN activity class is known, it then creates a new instance and calls onCreate(Bundle savedInstanceState) method. This method is the entry point to the application. - Show the APP
This is typically done by specifying the elements that a developer wants to display in a layout file stored inside res/layout subdirectory. Android makes it easy to refer to this file by automatically creating a reference to this file in an auto-generated java class R. All layout files can be referenced by adding a prefix R.layout. followed by name of the layout file (typically same as name of the activity). Developer can then instruct the OS to render it by invoking a method setContentView(R.layout.<layout_file_name>) .
This is the bare minimal a developer needs to understand how an Android application is started and what gets displayed on phone. You start building your app by adding logic to the onCreate() method and adding appropriate elements to the layout file.
Comments