Entrypoint Of Android Application
Solution 1:
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:12Instrumentation.callActivityOnCreate(Activity,Bundle)line:1047ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord,Intent)line:2627ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord,Intent)line:2679ActivityThread.access$2300(ActivityThread,ActivityThread$ActivityRecord,Intent)line:125ActivityThread$H.handleMessage(Message)line:2033ActivityThread$H(Handler).dispatchMessage(Message)line:99Looper.loop()line:123ActivityThread.main(String[])line:4627Method.invokeNative(Object,Object[],Class,Class[],Class,int,boolean)line:notavailable [nativemethod]
Method.invoke(Object,Object...)line:521ZygoteInit$MethodAndArgsCaller.run()line:868ZygoteInit.main(String[])line:626NativeStart.main(String[])line:notavailable [nativemethod]
Solution 2:
You should extend the Application class and override the onCreate method.
For reference:Application class
Solution 3:
I don't know it myself, but it sounds an interesting question. This is the code that fires a new Activity
and following the code, you'll end up in JNI code
publicvoidstartActivityForResult(Intent intent, int requestCode) {
if (mParent == null) {
Instrumentation.ActivityResultar=
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, this,
intent, requestCode);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, mEmbeddedID, requestCode, ar.getResultCode(),
ar.getResultData());
}
if (requestCode >= 0) {
// If this start is requesting a result, we can avoid making// the activity visible until the result is received. Setting// this code during onCreate(Bundle savedInstanceState) or onResume() will keep the// activity hidden during this time, to avoid flickering.// This can only be done when a result is requested because// that guarantees we will get information back when the// activity is finished, no matter what happens to it.
mStartedActivity = true;
}
} else {
mParent.startActivityFromChild(this, intent, requestCode);
}
}
Android source code is available, but it's a bit tricky to get it because it's poorly documented. You'll have to install repo
and then download the framework/base
project
Post a Comment for "Entrypoint Of Android Application"