ActivityGroup


public class ActivityGroup
extends Activity

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.view.ContextThemeWrapper
         ↳ android.app.Activity
           ↳ android.app.ActivityGroup


This class was deprecated in API level 13.
Use the new Fragment and FragmentManager APIs instead; these are also available on older platforms through the Android compatibility package.

A screen that contains and runs multiple embedded activities.

Summary

Inherited constants

Inherited fields

Public constructors

ActivityGroup()
ActivityGroup(boolean singleActivityMode)

Public methods

Activity getCurrentActivity()
final LocalActivityManager getLocalActivityManager()

Protected methods

void onCreate(Bundle savedInstanceState)

Called when the activity is starting.

void onDestroy()

Perform any final cleanup before an activity is destroyed.

void onPause()

Called as part of the activity lifecycle when the user no longer actively interacts with the activity, but it is still visible on screen.

void onResume()

Called after onRestoreInstanceState(Bundle), onRestart(), or onPause().

void onSaveInstanceState(Bundle outState)

Called to retrieve per-instance state from an activity before being killed so that the state can be restored in onCreate(Bundle) or onRestoreInstanceState(Bundle) (the Bundle populated by this method will be passed to both).

void onStop()

Called when you are no longer visible to the user.

Inherited methods

Public constructors

ActivityGroup

Added in API level 1
public ActivityGroup ()

ActivityGroup

Added in API level 1
public ActivityGroup (boolean singleActivityMode)

Parameters
singleActivityMode boolean

Public methods

getCurrentActivity

Added in API level 1
public Activity getCurrentActivity ()

Returns
Activity

getLocalActivityManager

Added in API level 1
public final LocalActivityManager getLocalActivityManager ()

Returns
LocalActivityManager

Protected methods

onCreate

Added in API level 1
protected void onCreate (Bundle savedInstanceState)

Called when the activity is starting. This is where most initialization should go: calling setContentView(int) to inflate the activity's UI, using findViewById(int) to programmatically interact with widgets in the UI, calling managedQuery(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.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(Bundle) without any of the rest of the activity lifecycle (onStart(), onResume(), 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.


This method must be called from the main thread of your app.
If you override this method you must call through to the superclass implementation.

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(Bundle). Note: Otherwise it is null.

onDestroy

Added in API level 1
protected void onDestroy ()

Perform any final cleanup before an activity is destroyed. This can happen either because the activity is finishing (someone called 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 isFinishing() method.

Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either onPause() or onSaveInstanceState(Bundle), not here. This method is usually implemented to free resources like threads that are associated with an activity, so that a destroyed activity does not leave such things around while the rest of its application is still running. There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

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


If you override this method you must call through to the superclass implementation.

onPause

Added in API level 1
protected void onPause ()

Called as part of the activity lifecycle when the user no longer actively interacts with the activity, but it is still visible on screen. The counterpart to onResume().

When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here.

This callback is mostly used for saving any persistent state the activity is editing, to present a "edit in place" model to the user and making sure nothing is lost if there are not enough resources to start the new activity without first killing this one. This is also a good place to stop things that consume a noticeable amount of CPU in order to make the switch to the next activity as fast as possible.

On platform versions prior to Build.VERSION_CODES.Q this is also a good place to try to close exclusive-access devices or to release access to singleton resources. Starting with Build.VERSION_CODES.Q there can be multiple resumed activities in the system at the same time, so onTopResumedActivityChanged(boolean) should be used for that purpose instead.

If an activity is launched on top, after receiving this call you will usually receive a following call to onStop() (after the next activity has been resumed and displayed above). However in some cases there will be a direct call back to onResume() without going through the stopped state. An activity can also rest in paused state in some cases when in multi-window mode, still visible to user.

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


If you override this method you must call through to the superclass implementation.

onResume

Added in API level 1
protected void onResume ()

Called after onRestoreInstanceState(Bundle), onRestart(), or onPause(). This is usually a hint for your activity to start interacting with the user, which is a good indicator that the activity became active and ready to receive input. This sometimes could also be a transit state toward another resting state. For instance, an activity may be relaunched to onPause() due to configuration changes and the activity was visible, but wasn't the top-most activity of an activity task. onResume() is guaranteed to be called before onPause() in this case which honors the activity lifecycle policy and the activity eventually rests in onPause().

On platform versions prior to Build.VERSION_CODES.Q this is also a good place to try to open exclusive-access devices or to get access to singleton resources. Starting with Build.VERSION_CODES.Q there can be multiple resumed activities in the system simultaneously, so onTopResumedActivityChanged(boolean) should be used for that purpose instead.

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


If you override this method you must call through to the superclass implementation.

onSaveInstanceState

Added in API level 1
protected void onSaveInstanceState (Bundle outState)

Called to retrieve per-instance state from an activity before being killed so that the state can be restored in onCreate(Bundle) or onRestoreInstanceState(Bundle) (the Bundle populated by this method will be passed to both).

This method is called before an activity may be killed so that when it comes back some time in the future it can restore its state. For example, if activity B is launched in front of activity A, and at some point activity A is killed to reclaim resources, activity A will have a chance to save the current state of its user interface via this method so that when the user returns to activity A, the state of the user interface can be restored via onCreate(Bundle) or onRestoreInstanceState(Bundle).

Do not confuse this method with activity lifecycle callbacks such as onPause(), which is always called when the user no longer actively interacts with an activity, or onStop() which is called when activity becomes invisible. One example of when onPause() and onStop() is called and not this method is when a user navigates back from activity B to activity A: there is no need to call onSaveInstanceState(Bundle) on B because that particular instance will never be restored, so the system avoids calling it. An example when onPause() is called and not onSaveInstanceState(Bundle) is when activity B is launched in front of activity A: the system may avoid calling onSaveInstanceState(Bundle) on activity A if it isn't killed during the lifetime of B since the state of the user interface of A will stay intact.

The default implementation takes care of most of the UI per-instance state for you by calling View.onSaveInstanceState() on each view in the hierarchy that has an id, and by saving the id of the currently focused view (all of which is restored by the default implementation of onRestoreInstanceState(Bundle)). If you override this method to save additional information not captured by each individual view, you will likely want to call through to the default implementation, otherwise be prepared to save all of the state of each view yourself.

If called, this method will occur after onStop() for applications targeting platforms starting with Build.VERSION_CODES.P. For applications targeting earlier platform versions this method will occur before onStop() and there are no guarantees about whether it will occur before or after onPause().

Parameters
outState Bundle: Bundle in which to place your saved state. This value cannot be null.

onStop

Added in API level 1
protected void onStop ()

Called when you are no longer visible to the user. You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity. This is a good place to stop refreshing UI, running animations and other visual things.

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


If you override this method you must call through to the superclass implementation.