Compartir a través de


Activity.OnCreate Method

Definition

Overloads

OnCreate(Bundle)

Called when the activity is starting.

OnCreate(Bundle, PersistableBundle)

Same as #onCreate(android.os.Bundle) but called for those activities created with the attribute android.R.attr#persistableMode set to persistAcrossReboots.

OnCreate(Bundle)

Called when the activity is starting.

[Android.Runtime.Register("onCreate", "(Landroid/os/Bundle;)V", "GetOnCreate_Landroid_os_Bundle_Handler")]
protected virtual void OnCreate (Android.OS.Bundle? savedInstanceState);
[<Android.Runtime.Register("onCreate", "(Landroid/os/Bundle;)V", "GetOnCreate_Landroid_os_Bundle_Handler")>]
abstract member OnCreate : Android.OS.Bundle -> unit
override this.OnCreate : Android.OS.Bundle -> unit

Parameters

savedInstanceState
Bundle

If the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in #onSaveInstanceState. <b>Note: Otherwise it is null.</b>

Attributes

Remarks

Called when the activity is starting. This is where most initialization should go: calling #setContentView(int) to inflate the activity's UI, using #findViewById to programmatically interact with widgets in the UI, calling #managedQuery(android.net.Uri , String[], String, String[], String) to retrieve cursors for data being displayed, etc.

You can call #finish from within this function, in which case onDestroy() will be immediately called after #onCreate without any of the rest of the activity lifecycle (#onStart, #onResume, #onPause, etc) executing.

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

Java documentation for android.app.Activity.onCreate(android.os.Bundle).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

OnCreate(Bundle, PersistableBundle)

Same as #onCreate(android.os.Bundle) but called for those activities created with the attribute android.R.attr#persistableMode set to persistAcrossReboots.

[Android.Runtime.Register("onCreate", "(Landroid/os/Bundle;Landroid/os/PersistableBundle;)V", "GetOnCreate_Landroid_os_Bundle_Landroid_os_PersistableBundle_Handler")]
public virtual void OnCreate (Android.OS.Bundle? savedInstanceState, Android.OS.PersistableBundle? persistentState);
[<Android.Runtime.Register("onCreate", "(Landroid/os/Bundle;Landroid/os/PersistableBundle;)V", "GetOnCreate_Landroid_os_Bundle_Landroid_os_PersistableBundle_Handler")>]
abstract member OnCreate : Android.OS.Bundle * Android.OS.PersistableBundle -> unit
override this.OnCreate : Android.OS.Bundle * Android.OS.PersistableBundle -> unit

Parameters

savedInstanceState
Bundle

if the activity is being re-initialized after previously being shut down then this Bundle contains the data it most recently supplied in #onSaveInstanceState. <b>Note: Otherwise it is null.</b>

persistentState
PersistableBundle

if the activity is being re-initialized after previously being shut down or powered off then this Bundle contains the data it most recently supplied to outPersistentState in #onSaveInstanceState. <b>Note: Otherwise it is null.</b>

Attributes

Remarks

Same as #onCreate(android.os.Bundle) but called for those activities created with the attribute android.R.attr#persistableMode set to persistAcrossReboots.

Java documentation for android.app.Activity.onCreate(android.os.Bundle, android.os.PersistableBundle).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to