dacongy dacongy - 23 days ago 6
Android Question

entrypoint of android application

When we develop an Android application, we always start from the

onCreate()
method of the main activity. It is obvious that there are some initializations that should be done before calling
onCreate()
. My question is: what is the entrypoint point (or the
main
method) of an Android application? What does the Dalvik VM invoke in the very beginning (i.e., when it finishes initialization of its own, and is about to transfer control to the application)? Where can I find the code of this
main
?

Answer

The first "entry" point is the application class as Kingston pointed out.

However, the easiest thing to get the very first starting point is to check the stack when debugging onCreate.

You may check Instrumentation, this sound somewhat like what you want.

http://developer.android.com/reference/android/app/Instrumentation.html

MainActivity.onCreate(Bundle) line: 12  
Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1047   
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2627  
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679   
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 
ActivityThread$H.handleMessage(Message) line: 2033  
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 123 
ActivityThread.main(String[]) line: 4627    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 521  
ZygoteInit$MethodAndArgsCaller.run() line: 868  
ZygoteInit.main(String[]) line: 626 
NativeStart.main(String[]) line: not available [native method]