Android Guides | Samples

Android.App.Activity Class

An activity is a single, focused thing that the user can do.

See Also: Activity


[Android.Runtime.Register("android/app/Activity", DoNotGenerateAcw=true)]
public class Activity : ContextThemeWrapper, IComponentCallbacks2, KeyEvent+ICallback, LayoutInflater+IFactory2, View+IOnCreateContextMenuListener, Window+ICallback, IDisposable


An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with Activity.SetContentView(View). While activities are often presented to the user as full-screen windows, they can also be used in other ways: as floating windows (via a theme with NoType:android/R$attr;Href=../../../reference/android/R.attr.html#windowIsFloating set) or embedded inside of another activity (using ActivityGroup). There are two methods almost all subclasses of Activity will implement:

To be of use with Context.StartActivity(Intent), all activity classes must have a corresponding NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestActivity declaration in their package's AndroidManifest.xml.

Topics covered here:

Developer Guides

The Activity class is an important part of an application's overall lifecycle, and the way activities are launched and put together is a fundamental part of the platform's application model. For a detailed perspective on the structure of an Android application and how activities behave, please read the Application Fundamentals and Tasks and Back Stack developer guides.

You can also find a detailed discussion about how to create activities in the Activities developer guide.


Starting with Build+VERSION_CODES.Honeycomb, Activity implementations can make use of the Fragment class to better modularize their code, build more sophisticated user interfaces for larger screens, and help scale their application between small and large screens.

Activity Lifecycle

Activities in the system are managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity -- the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits.

An activity has essentially four states:

  • If an activity in the foreground of the screen (at the top of the stack), it is active or running.
  • If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.
  • If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.
  • If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state.

The following diagram shows the important state paths of an Activity. The square rectangles represent callback methods you can implement to perform operations when the Activity moves between states. The colored ovals are major states the Activity can be in.

There are three key loops you may be interested in monitoring within your activity:

  • The entire lifetime of an activity happens between the first call to Activity.OnCreate(Bundle) through to a single final call to Activity.OnDestroy. An activity will do all setup of "global" state in onCreate(), and release all remaining resources in onDestroy(). For example, if it has a thread running in the background to download data from the network, it may create that thread in onCreate() and then stop the thread in onDestroy().
  • The visible lifetime of an activity happens between a call to Activity.OnStart until a corresponding call to Activity.OnStop. During this time the user can see the activity on-screen, though it may not be in the foreground and interacting with the user. Between these two methods you can maintain resources that are needed to show the activity to the user. For example, you can register a BroadcastReceiver in onStart() to monitor for changes that impact your UI, and unregister it in onStop() when the user no longer sees what you are displaying. The onStart() and onStop() methods can be called multiple times, as the activity becomes visible and hidden to the user.
  • The foreground lifetime of an activity happens between a call to Activity.OnResume until a corresponding call to Activity.OnPause. During this time the activity is in front of all other activities and interacting with the user. An activity can frequently go between the resumed and paused states -- for example when the device goes to sleep, when an activity result is delivered, when a new intent is delivered -- so the code in these methods should be fairly lightweight.

The entire lifecycle of an activity is defined by the following Activity methods. All of these are hooks that you can override to do appropriate work when the activity changes state. All activities will implement Activity.OnCreate(Bundle) to do their initial setup; many will also implement Activity.OnPause to commit changes to data and otherwise prepare to stop interacting with the user. You should always call up to your superclass when implementing these methods.

java Example

 public class Activity extends ApplicationContext {
     protected void onCreate(Bundle savedInstanceState);

     protected void onStart();

     protected void onRestart();

     protected void onResume();

     protected void onPause();

     protected void onStop();

     protected void onDestroy();

In general the movement through an activity's lifecycle looks like this:

Activity.OnCreate(Bundle)Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously frozen state, if there was one. Always followed by onStart().NoonStart()
    Activity.OnRestartCalled after your activity has been stopped, prior to it being started again. Always followed by onStart()NoonStart()
Activity.OnStartCalled when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.NoonResume() or onStop()
    Activity.OnResumeCalled when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it. Always followed by onPause().NoonPause()
Activity.OnPauseCalled when the system is about to start resuming a previous activity. This is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, etc. Implementations of this method must be very quick because the next activity will not be resumed until this method returns. Followed by either onResume() if the activity returns back to the front, or onStop() if it becomes invisible to the user.Pre-Build+VERSION_CODES.HoneycombonResume() or
Activity.OnStopCalled when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. This may happen either because a new activity is being started, an existing one is being brought in front of this one, or this one is being destroyed. Followed by either onRestart() if this activity is coming back to interact with the user, or onDestroy() if this activity is going away.YesonRestart() or
Activity.OnDestroyThe final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called Activity.Finish on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the Activity.IsFinishing method.Yesnothing

Note the "Killable" column in the above table -- for those methods that are marked as being killable, after that method returns the process hosting the activity may be killed by the system at any time without another line of its code being executed. Because of this, you should use the Activity.OnPause method to write any persistent data (such as user edits) to storage. In addition, the method Activity.OnSaveInstanceState(Bundle) is called before placing the activity in such a background state, allowing you to save away any dynamic instance state in your activity into the given Bundle, to be later received in Activity.OnCreate(Bundle) if the activity needs to be re-created. See the section for more information on how the lifecycle of a process is tied to the activities it is hosting. Note that it is important to save persistent data in Activity.OnPause instead of Activity.OnSaveInstanceState(Bundle) because the latter is not part of the lifecycle callbacks, so will not be called in every situation as described in its documentation.

Be aware that these semantics will change slightly between applications targeting platforms starting with Build+VERSION_CODES.Honeycomb vs. those targeting prior platforms. Starting with Honeycomb, an application is not in the killable state until its Activity.OnStop has returned. This impacts when Activity.OnSaveInstanceState(Bundle) may be called (it may be safely called after Activity.OnPause and allows and application to safely wait until Activity.OnStop to save persistent state.

For those methods that are not marked as being killable, the activity's process will not be killed by the system starting from the time the method is called and continuing after it returns. Thus an activity is in the killable state, for example, between after onPause() to the start of onResume().

Configuration Changes

If the configuration of the device (as defined by the Configuration class) changes, then anything displaying a user interface will need to update to match that configuration. Because Activity is the primary mechanism for interacting with the user, it includes special support for handling configuration changes.

Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of Activity.OnPause, Activity.OnStop, and Activity.OnDestroy as appropriate. If the activity had been in the foreground or visible to the user, once Activity.OnDestroy is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from Activity.OnSaveInstanceState(Bundle).

This is done because any application resource, including layout files, can change based on any configuration value. Thus the only safe way to handle a configuration change is to re-retrieve all resources, including layouts, drawables, and strings. Because activities must already know how to save their state and re-create themselves from that state, this is a convenient way to have an activity restart itself with a new configuration.

In some special cases, you may want to bypass restarting of your activity based on one or more types of configuration changes. This is done with the NoType:android/R$attr;Href=../../../reference/android/R.attr.html#configChanges attribute in its manifest. For any types of configuration changes you say that you handle there, you will receive a call to your current activity's Activity.OnConfigurationChanged(Configuration) method instead of being restarted. If a configuration change involves any that you do not handle, however, the activity will still be restarted and Activity.OnConfigurationChanged(Configuration) will not be called.

Starting Activities and Getting Results

The Context.StartActivity method is used to start a new activity, which will be placed at the top of the activity stack. It takes a single argument, an Intent, which describes the activity to be executed.

Sometimes you want to get a result back from an activity when it ends. For example, you may start an activity that lets the user pick a person in a list of contacts; when it ends, it returns the person that was selected. To do this, you call the Activity.StartActivityForResult(Intent,Int32) version with a second integer parameter identifying the call. The result will come back through your Activity.OnActivityResult(Int32,Result,Result) method.

When an activity exits, it can call Activity.SetResult(Result) to return data back to its parent. It must always supply a result code, which can be the standard results RESULT_CANCELED, RESULT_OK, or any custom values starting at RESULT_FIRST_USER. In addition, it can optionally return back an Intent containing any additional data it wants. All of this information appears back on the parent's Activity.onActivityResult(), along with the integer identifier it originally supplied.

If a child activity fails for any reason (such as crashing), the parent activity will receive a result with the code RESULT_CANCELED.

java Example

 public class MyActivity extends Activity {

     static final int PICK_CONTACT_REQUEST = 0;

     public boolean onKeyDown(int keyCode, KeyEvent event) {
         if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
             // When the user center presses, let them pick a contact.
                 new Intent(Intent.ACTION_PICK,
                 new Uri("content://contacts")),
            return true;
         return false;

     protected void onActivityResult(int requestCode, int resultCode,
             Intent data) {
         if (requestCode == PICK_CONTACT_REQUEST) {
             if (resultCode == RESULT_OK) {
                 // A contact was picked.  Here we will just display it
                 // to the user.
                 startActivity(new Intent(Intent.ACTION_VIEW, data));

Saving Persistent State

There are generally two kinds of persistent state than an activity will deal with: shared document-like data (typically stored in a SQLite database using a ContentProvider) and internal state such as user preferences.

For content provider data, we suggest that activities use a "edit in place" user model. That is, any edits a user makes are effectively made immediately without requiring an additional confirmation step. Supporting this model is generally a simple matter of following two rules:

When creating a new document, the backing database entry or file for it is created immediately. For example, if the user chooses to write a new e-mail, a new entry for that e-mail is created as soon as they start entering data, so that if they go to any other activity after that point this e-mail will now appear in the list of drafts.

When an activity's onPause() method is called, it should commit to the backing content provider or file any changes the user has made. This ensures that those changes will be seen by any other activity that is about to run. You will probably want to commit your data even more aggressively at key times during your activity's lifecycle: for example before starting a new activity, before finishing your own activity, when the user switches between input fields, etc.

This model is designed to prevent data loss when a user is navigating between activities, and allows the system to safely kill an activity (because system resources are needed somewhere else) at any time after it has been paused. Note this implies that the user pressing BACK from your activity does not mean "cancel" -- it means to leave the activity with its current contents saved away. Canceling edits in an activity must be provided through some other mechanism, such as an explicit "revert" or "undo" option.

See the ContentProvider for more information about content providers. These are a key aspect of how different activities invoke and propagate data between themselves.

The Activity class also provides an API for managing internal persistent state associated with an activity. This can be used, for example, to remember the user's preferred initial display in a calendar (day view or week view) or the user's default home page in a web browser.

Activity persistent state is managed with the method Activity.GetPreferences(FileCreationMode), allowing you to retrieve and modify a set of name/value pairs associated with the activity. To use preferences that are shared across multiple application components (activities, receivers, services, providers), you can use the underlying Context.GetSharedPreferences(String,FileCreationMode) method to retrieve a preferences object stored under a specific name. (Note that it is not possible to share settings data across application packages -- for that you will need a content provider.)

Here is an excerpt from a calendar activity that stores the user's preferred view mode in its persistent settings:

java Example

 public class CalendarActivity extends Activity {

     static final int DAY_VIEW_MODE = 0;
     static final int WEEK_VIEW_MODE = 1;

     private SharedPreferences mPrefs;
     private int mCurViewMode;

     protected void onCreate(Bundle savedInstanceState) {

         SharedPreferences mPrefs = getSharedPreferences();
         mCurViewMode = mPrefs.getInt("view_mode", DAY_VIEW_MODE);

     protected void onPause() {

         SharedPreferences.Editor ed = mPrefs.edit();
         ed.putInt("view_mode", mCurViewMode);


The ability to start a particular Activity can be enforced when it is declared in its manifest's NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestActivity tag. By doing so, other applications will need to declare a corresponding NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestUsesPermission element in their own manifest to be able to start that activity.

When starting an Activity you can set ActivityFlags.GrantReadUriPermission and/or ActivityFlags.GrantWriteUriPermission on the Intent. This will grant the Activity access to the specific URIs in the Intent. Access will remain until the Activity has finished (it will remain across the hosting process being killed and other temporary destruction). As of NoType:android/os/Build$VERSION_CODES;Href=../../../reference/android/os/Build.VERSION_CODES.html#GINGERBREAD, if the Activity was already created and a new Intent is being delivered to Activity.OnNewIntent(Intent), any newly granted URI permissions will be added to the existing ones it holds.

See the Security and Permissions document for more information on permissions and security in general.

Process Lifecycle

The Android system attempts to keep application process around for as long as possible, but eventually will need to remove old processes when memory runs low. As described in , the decision about which process to remove is intimately tied to the state of the user's interaction with it. In general, there are four states a process can be in based on the activities running in it, listed here in order of importance. The system will kill less important processes (the last ones) before it resorts to killing more important processes (the first ones).

  1. The foreground activity (the activity at the top of the screen that the user is currently interacting with) is considered the most important. Its process will only be killed as a last resort, if it uses more memory than is available on the device. Generally at this point the device has reached a memory paging state, so this is required in order to keep the user interface responsive.
  2. A visible activity (an activity that is visible to the user but not in the foreground, such as one sitting behind a foreground dialog) is considered extremely important and will not be killed unless that is required to keep the foreground activity running.
  3. A background activity (an activity that is not visible to the user and has been paused) is no longer critical, so the system may safely kill its process to reclaim memory for other foreground or visible processes. If its process needs to be killed, when the user navigates back to the activity (making it visible on the screen again), its Activity.OnCreate(Bundle) method will be called with the savedInstanceState it had previously supplied in Activity.OnSaveInstanceState(Bundle) so that it can restart itself in the same state as the user last left it.
  4. An empty process is one hosting no activities or other application components (such as Service or BroadcastReceiver classes). These are killed very quickly by the system as memory becomes low. For this reason, any background operation you do outside of an activity must be executed in the context of an activity BroadcastReceiver or Service to ensure that the system knows it needs to keep your process around.

Sometimes an Activity may need to do a long-running operation that exists independently of the activity lifecycle itself. An example may be a camera application that allows you to upload a picture to a web site. The upload may take a long time, and the application should allow the user to leave the application will it is executing. To accomplish this, your Activity should start a Service in which the upload takes place. This allows the system to properly prioritize your process (considering it to be more important than other non-visible applications) for the duration of the upload, independent of whether the original activity is paused, stopped, or finished.

[Android Documentation]


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

The members of Android.App.Activity are listed below.

See Also: ContextThemeWrapper

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

ActionBarActionBar. Retrieve a reference to this activity's ActionBar.
ApplicationApplication. Return the application that owns this activity.
CallingActivityComponentName. Return the name of the activity that invoked this activity.
CallingPackageString. Return the name of the package that invoked this activity.
ChangingConfigurationsConfigChanges. If this activity is being destroyed because it can not handle a configuration parameter being changed (and thus its Activity.OnConfigurationChanged(Configuration) method is not being called), then you can use this method to discover the set of changes that have occurred while in the process of being destroyed.
ComponentNameComponentName. Returns complete component name of this activity.
ContentSceneScene. Retrieve the Scene representing this window's current content.
ContentTransitionManagerTransitionManager. Retrieve the TransitionManager responsible for default transitions in this window.
CurrentFocusView. Calls Window.CurrentFocus on the Window of this Activity to return the currently focused view.
FragmentManagerFragmentManager. Return the FragmentManager for interacting with fragments associated with this activity.
HasWindowFocusBoolean. Returns true if this activity's main window currently has window focus.
ImmersiveBoolean. Bit indicating that this activity is "immersive" and should not be interrupted by notifications if possible.
IntentIntent. Return the intent that started this activity.
IsChangingConfigurationsBoolean. Check to see whether this activity is in the process of being destroyed in order to be recreated with a new configuration.
IsChildBoolean. Is this activity embedded inside of another activity?
IsDestroyedBoolean. Returns true if the final Activity.OnDestroy call has been made on the Activity, so this instance is now dead.
IsFinishingBoolean. Check to see whether this activity is in the process of finishing, either because you called Activity.Finish on it or someone else has requested that it finished.
IsTaskRootBoolean. Return whether this activity is the root of a task.
LastNonConfigurationInstanceObject. Retrieve the non-configuration instance data that was previously returned by Activity.OnRetainNonConfigurationInstance.
LayoutInflaterLayoutInflater. Convenience for calling Window.LayoutInflater.
LoaderManagerLoaderManager. Return the LoaderManager for this activity, creating it if needed.
LocalClassNameString. Returns class name for this activity with the package prefix removed.
MediaControllerMediaController. Gets the controller which should be receiving media key and volume events while this activity is in the foreground.
MenuInflaterMenuInflater. Returns a MenuInflater with this context.
ParentActivity. Return the parent activity if this view is an embedded child.
ParentActivityIntentIntent. Obtain an Intent that will launch an explicit target activity specified by this activity's logical parent.
RequestedOrientationScreenOrientation. Return the current requested orientation of the activity.
TaskIdInt32. Return the identifier of the task this activity is in.
VolumeControlStreamStream. Gets the suggested audio stream whose volume should be changed by the hardware volume controls.
WindowWindow. Retrieve the current Window for the activity.
WindowManagerIWindowManager. Retrieve the window manager for showing custom windows.

Protected Properties

ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddContentView(View, ViewGroup+LayoutParams)
Add an additional content view to the activity.
Programmatically closes the most recently opened context menu, if showing.
Progammatically closes the options menu.
CreatePendingResult(Int32, Intent, PendingIntentFlags) : PendingIntent
Create a new PendingIntent object which you can hand to others for them to use to send result data back to your Activity.OnActivityResult(Int32,Result,Result) callback.
Dismiss a dialog that was previously shown via Activity.ShowDialog(Int32).
DispatchGenericMotionEvent(MotionEvent) : Boolean
Called to process generic motion events.
DispatchKeyEvent(KeyEvent) : Boolean
Called to process key events.
DispatchKeyShortcutEvent(KeyEvent) : Boolean
Called to process a key shortcut event.
DispatchPopulateAccessibilityEvent(AccessibilityEvent) : Boolean
Called to process population of AccessibilityEvents.
DispatchTouchEvent(MotionEvent) : Boolean
Called to process touch screen events.
DispatchTrackballEvent(MotionEvent) : Boolean
Called to process trackball events.
Dump(String, FileDescriptor, PrintWriter, String[])
Print the Activity's state into the given stream.
FindViewById(Int32) : View
Finds a view that was identified by the id attribute from the XML that was processed in Activity.OnCreate(Bundle).
FindViewById<T>(Int32) : T
Finds a view that was identified by the id attribute from the XML layout resource.
Call this when your activity is done and should be closed.
Force finish another activity that you had previously started with Activity.StartActivityForResult(Intent,Int32).
FinishActivityFromChild(Activity, Int32)
This is called when a child activity of this one calls its finishActivity().
Finish this activity as well as all activities immediately below it in the current task that have the same affinity.
Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.
Call this when your activity is done and should be closed and the task should be completely removed as a part of finishing the Activity.
This is called when a child activity of this one calls its Activity.Finish method.
GetPreferences(FileCreationMode) : ISharedPreferences
Retrieve a ISharedPreferences object for accessing preferences that are private to this activity.
Declare that the options menu has changed, so should be recreated.
ManagedQuery(Uri, String[], String, String[], String) : ICursor
Wrapper around ContentResolver.Query(Uri,String[],String[],String[],String[]) that gives the resulting ICursor to call Activity.StartManagingCursor(ICursor) so that the activity will manage its lifecycle for you.
MoveTaskToBack(Boolean) : Boolean
Move the task containing this activity to the back of the activity stack.
NavigateUpTo(Intent) : Boolean
Navigate from this activity to the activity specified by upIntent, finishing this activity in the process.
NavigateUpToFromChild(Activity, Intent) : Boolean
This is called when a child activity of this one calls its Activity.NavigateUpTo(Intent) method.
Notifies the activity that an action mode has finished.
Notifies the Activity that an action mode has been started.
OnActivityReenter(Int32, Intent)
Called when an activity you launched with an activity transition exposes this Activity through a returning activity transition, giving you the resultCode and any additional data from it.
Called when the main window associated with the activity has been attached to the window manager.
Called when a Fragment is being attached to this activity, immediately after the call to its Fragment.OnAttach(Activity) method and before Fragment.OnCreate(Bundle).
Called when the activity has detected the user's press of the back key.
Called by the system when the device configuration changes while your activity is running.
This hook is called whenever the content view of the screen changes (due to a call to Android.Views.Window.SetContentView(Android.Views.View, .LayoutParams) or Android.Views.Window.AddContentView(Android.Views.View, .LayoutParams)).
OnContextItemSelected(IMenuItem) : Boolean
This hook is called whenever an item in a context menu is selected.
This hook is called whenever the context menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).
OnCreate(Bundle, PersistableBundle)
Same as Activity.OnCreate(Bundle) but called for those activities created with the attribute NoType:android/R$attr;Href=../../../reference/android/R.attr.html#persistableMode set to persistAcrossReboots.
OnCreateContextMenu(IContextMenu, View, IContextMenuContextMenuInfo)
Called when a context menu for the view is about to be shown.
OnCreateDescription() : String
OnCreateDescriptionFormatted() : ICharSequence
Generate a new description for this activity.
Define the synthetic task stack that will be generated during Up navigation from a different task.
OnCreateOptionsMenu(IMenu) : Boolean
Initialize the contents of the Activity's standard options menu.
OnCreatePanelMenu(Int32, IMenu) : Boolean
Default implementation of NoType:android/view/Window$Callback;Href=../../../reference/android/view/Window.Callback.html#onCreatePanelMenu(int, android.view.Menu) for activities.
OnCreatePanelView(Int32) : View
Default implementation of NoType:android/view/Window$Callback;Href=../../../reference/android/view/Window.Callback.html#onCreatePanelView(int) for activities.
OnCreateThumbnail(Bitmap, Canvas) : Boolean
Generate a new thumbnail for this activity.
OnCreateView(String, Context, IAttributeSet) : View
Standard implementation of NoType:android/view/LayoutInflater$Factory;Href=../../../reference/android/view/LayoutInflater.Factory.html#onCreateView(java.lang.String, android.content.Context, android.util.AttributeSet) used when inflating with the LayoutInflater returned by Context.GetSystemService(String).
OnCreateView(View, String, Context, IAttributeSet) : View
Standard implementation of NoType:android/view/LayoutInflater$Factory2;Href=../../../reference/android/view/LayoutInflater.Factory2.html#onCreateView(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) used when inflating with the LayoutInflater returned by Context.GetSystemService(String).
Called when the main window associated with the activity has been detached from the window manager.
Activities cannot draw during the period that their windows are animating in.
OnGenericMotionEvent(MotionEvent) : Boolean
Called when a generic motion event was not handled by any of the views inside of the activity.
OnKeyDown(Keycode, KeyEvent) : Boolean
Called when a key was pressed down and not handled by any of the views inside of the activity.
OnKeyLongPress(Keycode, KeyEvent) : Boolean
Default implementation of NoType:android/view/KeyEvent$Callback;Href=../../../reference/android/view/KeyEvent.Callback.html#onKeyLongPress(int, android.view.KeyEvent): always returns false (doesn't handle the event).
OnKeyMultiple(Keycode, Int32, KeyEvent) : Boolean
Default implementation of NoType:android/view/KeyEvent$Callback;Href=../../../reference/android/view/KeyEvent.Callback.html#onKeyMultiple(int, int, android.view.KeyEvent): always returns false (doesn't handle the event).
OnKeyShortcut(Keycode, KeyEvent) : Boolean
Called when a key shortcut event is not handled by any of the views in the Activity.
OnKeyUp(Keycode, KeyEvent) : Boolean
Called when a key was released and not handled by any of the views inside of the activity.
This is called when the overall system is running low on memory, and actively running processes should trim their memory usage.
OnMenuItemSelected(Int32, IMenuItem) : Boolean
Default implementation of NoType:android/view/Window$Callback;Href=../../../reference/android/view/Window.Callback.html#onMenuItemSelected(int, android.view.MenuItem) for activities.
OnMenuOpened(Int32, IMenu) : Boolean
Called when a panel's menu is opened by the user.
OnNavigateUp() : Boolean
This method is called whenever the user chooses to navigate Up within your application's activity hierarchy from the action bar.
OnNavigateUpFromChild(Activity) : Boolean
This is called when a child activity of this one attempts to navigate up.
OnOptionsItemSelected(IMenuItem) : Boolean
This hook is called whenever an item in your options menu is selected.
This hook is called whenever the options menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).
OnPanelClosed(Int32, IMenu)
Default implementation of NoType:android/view/Window$Callback;Href=../../../reference/android/view/Window.Callback.html#onPanelClosed(int, android.view.Menu) for activities.
OnPostCreate(Bundle, PersistableBundle)
This is the same as Activity.OnPostCreate(Bundle) but is called for activities created with the attribute NoType:android/R$attr;Href=../../../reference/android/R.attr.html#persistableMode set to persistAcrossReboots.
Prepare the synthetic task stack that will be generated during Up navigation from a different task.
OnPrepareOptionsMenu(IMenu) : Boolean
Prepare the Screen's standard options menu to be displayed.
OnPreparePanel(Int32, View, IMenu) : Boolean
Default implementation of NoType:android/view/Window$Callback;Href=../../../reference/android/view/Window.Callback.html#onPreparePanel(int, android.view.View, android.view.Menu) for activities.
This is called when the user is requesting an assist, to build a full Intent.ActionAssist Intent with all of the context of the current application.
OnRestoreInstanceState(Bundle, PersistableBundle)
This is the same as Activity.OnRestoreInstanceState(Bundle) but is called for activities created with the attribute NoType:android/R$attr;Href=../../../reference/android/R.attr.html#persistableMode set to persistAcrossReboots.
OnRetainNonConfigurationInstance() : Object
Called by the system, as part of destroying an activity due to a configuration change, when it is known that a new instance will immediately be created for the new configuration.
OnSaveInstanceState(Bundle, PersistableBundle)
This is the same as Activity.OnSaveInstanceState(Bundle) but is called for activities created with the attribute NoType:android/R$attr;Href=../../../reference/android/R.attr.html#persistableMode set to persistAcrossReboots.
OnSearchRequested() : Boolean
Called when the user signals the desire to start a search.
OnTouchEvent(MotionEvent) : Boolean
Called when a touch screen event was not handled by any of the views under it.
OnTrackballEvent(MotionEvent) : Boolean
Called when the trackball was moved and not handled by any of the views inside of the activity.
Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.
Called whenever a key, touch, or trackball event is dispatched to the activity.
Called when a translucent activity over this activity is becoming opaque or another activity is being launched.
This is called whenever the current window attributes change.
Called when the current Window of the activity gains or loses focus.
OnWindowStartingActionMode(ActionMode+ICallback) : ActionMode
Give the Activity a chance to control the UI for an action mode requested by the system.
Programmatically opens the context menu for a particular view.
Programmatically opens the options menu.
OverridePendingTransition(Int32, Int32)
Call immediately after one of the flavors of Context.StartActivity or Activity.Finish to specify an explicit transition animation to perform next.
Postpone the entering activity transition when Activity was started with ActivityOptions.makeSceneTransitionAnimation(, android.util.Pair<android.view.View, java.lang.String>...).
Cause this Activity to be recreated with a new instance.
Registers a context menu to be shown for the given view (multiple views can show the context menu).
ReleaseInstance() : Boolean
Ask that the local app instance of this activity be released to free up its memory.
Removes any internal references to a dialog managed by this Activity.
Report to the system that your app is now fully drawn, purely for diagnostic purposes (calling it does not impact the visible behavior of the activity).
RequestVisibleBehind(Boolean) : Boolean
Activities that want to remain visible behind a translucent activity above them must call this method anytime between the start of Activity.OnResume and the return from Activity.OnPause.
RequestWindowFeature(WindowFeatures) : Boolean
Enable extended window features.
Runs the specified action on the UI thread.
Set a Toolbar to act as the ActionBar for this Activity window.
Set the activity content to an explicit view.
Set the activity content from a layout resource.
SetContentView(View, ViewGroup+LayoutParams)
Set the activity content to an explicit view.
Select the default key handling for this activity.
When ActivityOptions.MakeSceneTransitionAnimation(Activity,View,View) was used to start an Activity, callback will be called to handle shared elements on the launched Activity.
When ActivityOptions.MakeSceneTransitionAnimation(Activity,View,View) was used to start an Activity, callback will be called to handle shared elements on the launching Activity.
SetFeatureDrawable(WindowFeatures, Drawable)
Convenience for calling Window.SetFeatureDrawable(WindowFeatures,Drawable).
SetFeatureDrawableAlpha(WindowFeatures, Int32)
Convenience for calling Window.SetFeatureDrawableAlpha(WindowFeatures,Int32).
SetFeatureDrawableResource(WindowFeatures, Int32)
Convenience for calling Window.SetFeatureDrawableResource(WindowFeatures,Int32).
SetFeatureDrawableUri(WindowFeatures, Uri)
Convenience for calling Window.SetFeatureDrawableUri(WindowFeatures,Uri).
Sets whether this activity is finished when touched outside its window's bounds.
Sets the progress for the progress bars in the title.
Sets whether the horizontal progress bar in the title should be indeterminate (the circular is always indeterminate).
Sets the visibility of the indeterminate progress bar in the title.
Sets the visibility of the progress bar in the title.
Call this to set the result that your activity will return to its caller.
SetResult(Result, Intent)
Call this to set the result that your activity will return to its caller.
Sets the secondary progress for the progress bar in the title.
Sets information describing the task with this activity for presentation inside the Recents System UI.
Change the title associated with this activity.
Control whether this activity's main window is visible.
ShouldUpRecreateTask(Intent) : Boolean
Returns true if the app should recreate the task when navigating 'up' from this activity by using targetIntent.
Simple version of Activity.ShowDialog(Int32,Bundle) that does not take any arguments.
ShowDialog(Int32, Bundle) : Boolean
Show a dialog managed by this activity.
StartActionMode(ActionMode+ICallback) : ActionMode
Start an action mode of the default type Android.Views.ActionMode.TYPE_PRIMARY.
StartActivityForResult(Intent, Int32)
Same as calling Activity.StartActivityForResult(Intent,Int32,Int32) with no options.
StartActivityForResult(Type, Int32)
StartActivityForResult(Intent, Int32, Bundle)
Launch an activity for which you would like a result when it finished.
StartActivityFromChild(Activity, Intent, Int32)
Same as calling Activity.StartActivityFromChild(Activity,Intent,Intent,Intent) with no options.
StartActivityFromChild(Activity, Intent, Int32, Bundle)
This is called when a child activity of this one calls its Context.StartActivity or Activity.StartActivityForResult(Intent,Int32) method.
StartActivityFromFragment(Fragment, Intent, Int32)
Same as calling Activity.StartActivityFromFragment(Fragment,Intent,Intent,Intent) with no options.
StartActivityFromFragment(Fragment, Intent, Int32, Bundle)
This is called when a Fragment in this activity calls its Fragment.StartActivity(Intent) or Fragment.StartActivityForResult(Intent,Int32) method.
StartActivityIfNeeded(Intent, Int32) : Boolean
Same as calling Activity.StartActivityIfNeeded(Intent,Int32,Int32) with no options.
StartActivityIfNeeded(Intent, Int32, Bundle) : Boolean
A special variation to launch an activity only if a new activity instance is needed to handle the given Intent.
StartIntentSenderForResult(IntentSender, Int32, Intent, ActivityFlags, ActivityFlags, Int32)
Same as calling Activity.StartIntentSenderForResult(IntentSender,Int32,Int32,Int32,Int32,Int32,Int32) with no options.
StartIntentSenderForResult(IntentSender, Int32, Intent, ActivityFlags, ActivityFlags, Int32, Bundle)
Like Activity.StartActivityForResult(Intent,Int32), but allowing you to use a IntentSender to describe the activity to be started.
StartIntentSenderFromChild(Activity, IntentSender, Int32, Intent, ActivityFlags, ActivityFlags, Int32)
Same as calling Activity.StartIntentSenderFromChild(Activity,IntentSender,IntentSender,IntentSender,IntentSender,IntentSender,IntentSender,IntentSender) with no options.
StartIntentSenderFromChild(Activity, IntentSender, Int32, Intent, ActivityFlags, ActivityFlags, Int32, Bundle)
Like Activity.StartActivityFromChild(Activity,Intent,Intent), but taking a IntentSender; see Activity.StartIntentSenderForResult(IntentSender,Int32,Int32,Int32,Int32,Int32) for more information.
Request to put this Activity in a mode where the user is locked to the current task.
This method allows the activity to take care of managing the given ICursor's lifecycle for you based on the activity's lifecycle.
StartNextMatchingActivity(Intent) : Boolean
Same as calling Activity.StartNextMatchingActivity(Intent,Bundle) with no options.
StartNextMatchingActivity(Intent, Bundle) : Boolean
Special version of starting an activity, for use when you are replacing other activity components.
Begin postponed transitions after Activity.PostponeEnterTransition was called.
StartSearch(String, Boolean, Bundle, Boolean)
This hook is called to launch the search UI.
Allow the user to switch away from the current task.
Given a Cursor that was previously given to Activity.StartManagingCursor(ICursor), stop the activity's management of that cursor.
Request that key events come to this activity.
TriggerSearch(String, Bundle)
Similar to Activity.StartSearch(String,Boolean,Boolean,Boolean), but actually fires off the search query after invoking the search dialog.
Prevents a context menu to be shown for the given view.

Protected Methods

OnActivityResult(Int32, Result, Intent)
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it.
OnChildTitleChanged(Activity, ICharSequence)
OnChildTitleChanged(Activity, String)
Called when the activity is starting.
OnCreateDialog(Int32) : Dialog
OnCreateDialog(Int32, Bundle) : Dialog
Callback for creating dialogs that are managed (saved and restored) for you by the activity.
Perform any final cleanup before an activity is destroyed.
This is called for activities that set launchMode to "singleTop" in their package, or if a client used the Android.Content.Intent.FLAG_ACTIVITY_SINGLE_TOP flag when calling Context.StartActivity.
Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed.
Called when activity start-up is complete (after Activity.OnStart and Activity.OnRestoreInstanceState(Bundle) have been called).
Called when activity resume is complete (after Activity.OnResume has been called).
OnPrepareDialog(Int32, Dialog)
OnPrepareDialog(Int32, Dialog, Bundle)
Provides an opportunity to prepare a managed dialog before it is being shown.
Called after Activity.OnStop when the current activity is being re-displayed to the user (the user has navigated back to it).
This method is called after Activity.OnStart when the activity is being re-initialized from a previously saved state, given here in savedInstanceState.
Called after Activity.OnRestoreInstanceState(Bundle), Activity.OnRestart, or Activity.OnPause, for your activity to start interacting with the user.
Called to retrieve per-instance state from an activity before being killed so that the state can be restored in Activity.OnCreate(Bundle) or Activity.OnRestoreInstanceState(Bundle) (the Bundle populated by this method will be passed to both).
Called after Activity.OnCreate(Bundle) &mdash; or after Activity.OnRestart when the activity had been stopped, but is now again being displayed to the user.
Called when you are no longer visible to the user.
OnTitleChanged(ICharSequence, Color)
OnTitleChanged(String, Color)
Called as part of the activity lifecycle when an activity is about to go into the background as the result of user choice.