Android Guides | Samples

Android.App.Activity.OnCreate Method

Called when the activity is starting.

Syntax

[Android.Runtime.Register("onCreate", "(Landroid/os/Bundle;)V", "GetOnCreate_Landroid_os_Bundle_Handler")]
protected virtual Void OnCreate (Bundle savedInstanceState)

See Also

Parameters

savedInstanceState
If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in Activity.OnSaveInstanceState(Bundle). Note: Otherwise it is null.

Remarks

Called when the activity is starting. This is where most initialization should go: calling Activity.SetContentView(Int32) to inflate the activity's UI, using Activity.FindViewById(Int32) to programmatically interact with widgets in the UI, calling Activity.ManagedQuery(Uri,String[],String[],String[],String[]) to retrieve cursors for data being displayed, etc.

You can call Activity.Finish from within this function, in which case onDestroy() will be immediately called without any of the rest of the activity lifecycle (Activity.OnStart, Activity.OnResume, Activity.OnPause, etc) executing.

Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1