2011年6月9日木曜日

Application Startup

When an activity, service, etc. is launched, Android will read your application's AndroidManifest.xml and read the appropriate /manifest/application/@android:name attribute to determine the name of an android.app.Application subclass to load. Once an instance of the specified Application is created, Application.onCreate() is invoked. All MonoDroid applications will specify an Application, and Application.onCreate() is overridden to initialize the Mono runtime.

Once the Application has been created, AndroidManifest.xml is again consulted to find the class name of the activity/service/etc. to launch. For example, the /manifest/application/activity/@android:name attribute is used to determine the name of an Activity to load. For Activities, this type must inherit android.app.Activity, and once the type is loaded the Activity.onCreate(Bundle) method will be invoked; Activity.onCreate(Bundle) is, conceptually, the classic Main() entrypoint method going by a different mechanism.

Android.App.Activity is the equivalent activity base class for managed code, and the Activity.OnCreate(Bundle) method is invoked during activity startup.

This works via the Android Callable Wrapper generated by monodroid.exe during the build process the name of the Android Callable Wrapper name is placed into the /manifest/application/activity/@android:name attribute value within AndroidManifest.xml.

Thus, Android loads and runs the Android Callable Wrapper (ACW), which in turn registers the ACW with the corresponding managed type before invoking the native method, transferring control to the overriden Android.OnCreate() method in managed code.

0 件のコメント:

コメントを投稿