java.lang.Object | |||||
↳ | android.content.Context | ||||
↳ | android.content.ContextWrapper | ||||
↳ | android.view.ContextThemeWrapper | ||||
↳ | android.app.Activity | ||||
↳ | android.support.v4.app.FragmentActivity |
Known Direct Subclasses
|
Base class for activities that want to use the support-based
Fragment
and
Loader
APIs.
When using this class as opposed to new platform's built-in fragment
and loader support, you must use the
getSupportFragmentManager()
and
getSupportLoaderManager()
methods respectively to access
those features.
Note:
If you want to implement an activity that includes
an
action bar
, you should instead use
the
ActionBarActivity
class, which is a subclass of this one,
so allows you to use
Fragment
APIs on API level 7 and higher.
Known limitations:
When using the
<fragment>
tag, this implementation can not
use the parent view's ID as the new fragment's ID. You must explicitly
specify an ID (or tag) in the
<fragment>
.
Prior to Honeycomb (3.0), an activity's state was saved before pausing. Fragments are a significant amount of new state, and dynamic enough that one often wants them to change between pausing and stopping. These classes throw an exception if you try to change the fragment state after it has been saved, to avoid accidental loss of UI state. However this is too restrictive prior to Honeycomb, where the state is saved before pausing. To address this, when running on platforms prior to Honeycomb an exception will not be thrown if you change fragments between the state save and the activity being stopped. This means that in some cases if the activity is restored from its last saved state, this may be a snapshot slightly before what the user last saw.
[Expand]
Inherited Constants
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Activity
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks2
|
[Expand]
Inherited Fields
|
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Activity
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Print the Activity's state into the given stream.
|
||||||||||
|
Return the value previously returned from
onRetainCustomNonConfigurationInstance()
.
|
||||||||||
|
Return the FragmentManager for interacting with fragments associated
with this activity.
|
||||||||||
|
Return the LoaderManager for this fragment, creating it if needed.
|
||||||||||
|
Called when a fragment is attached to the activity.
|
||||||||||
|
Take care of popping the fragment back stack or finishing the activity
as appropriate.
|
||||||||||
|
Dispatch configuration change to all fragments.
|
||||||||||
|
Dispatch to Fragment.onCreateOptionsMenu().
|
||||||||||
|
Add support for inflating the <fragment> tag.
|
||||||||||
|
Take care of calling onBackPressed() for pre-Eclair platforms.
|
||||||||||
|
Dispatch onLowMemory() to all fragments.
|
||||||||||
|
Dispatch context and options menu to fragments.
|
||||||||||
|
Call onOptionsMenuClosed() on fragments.
|
||||||||||
|
Dispatch onPrepareOptionsMenu() to fragments.
|
||||||||||
|
Use this instead of
onRetainNonConfigurationInstance()
.
|
||||||||||
|
This method is deprecated.
Use the new
Fragment
API
setRetainInstance(boolean)
instead; this is also
available on older platforms through the Android compatibility package.
|
||||||||||
|
Modifies the standard behavior to allow results to be delivered to fragments.
|
||||||||||
|
Called by Fragment.startActivityForResult() to implement its behavior.
|
||||||||||
|
Support library version of
invalidateOptionsMenu()
.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Dispatch incoming result to the correct fragment.
|
||||||||||
|
Perform initialization of all fragments and loaders.
|
||||||||||
|
Destroy all fragments and loaders.
|
||||||||||
|
Handle onNewIntent() to inform the fragment manager that the
state is not saved.
|
||||||||||
|
Dispatch onPause() to fragments.
|
||||||||||
|
Dispatch onResume() to fragments.
|
||||||||||
|
Dispatch onResume() to fragments.
|
||||||||||
|
This is the fragment-orientated version of
onResume()
that you
can override to perform operations in the Activity at the same point
where its fragments are resumed.
|
||||||||||
|
Save all appropriate fragment state.
|
||||||||||
|
Dispatch onStart() to all fragments.
|
||||||||||
|
Dispatch onStop() to all fragments.
|
[Expand]
Inherited Methods
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Activity
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.view.ContextThemeWrapper
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.ContextWrapper
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
java.lang.Object
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks2
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.KeyEvent.Callback
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.LayoutInflater.Factory
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.LayoutInflater.Factory2
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.View.OnCreateContextMenuListener
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.view.Window.Callback
|
Print the Activity's state into the given stream. This gets invoked if
you run "adb shell dumpsys activity
prefix | Desired prefix to prepend at each line of output. |
---|---|
fd | The raw file descriptor that the dump is being sent to. |
writer | The PrintWriter to which you should dump your state. This will be closed for you after you return. |
args | additional arguments to the dump request. |
Return the value previously returned from
onRetainCustomNonConfigurationInstance()
.
Return the FragmentManager for interacting with fragments associated with this activity.
Return the LoaderManager for this fragment, creating it if needed.
Called when a fragment is attached to the activity.
Take care of popping the fragment back stack or finishing the activity as appropriate.
Dispatch configuration change to all fragments.
newConfig | The new device configuration. |
---|
Dispatch to Fragment.onCreateOptionsMenu().
featureId | The panel being created. |
---|---|
menu | The menu inside the panel. |
Add support for inflating the <fragment> tag.
name | Tag name to be inflated. |
---|---|
context | The context the view is being created in. |
attrs | Inflation attributes as specified in XML file. |
Take care of calling onBackPressed() for pre-Eclair platforms.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
true
to prevent this event from being propagated
further, or
false
to indicate that you have not handled
this event and it should continue to be propagated.
Dispatch onLowMemory() to all fragments.
Dispatch context and options menu to fragments.
featureId | The panel that the menu is in. |
---|---|
item | The menu item that was selected. |
Call onOptionsMenuClosed() on fragments.
featureId | The panel that is being displayed. |
---|---|
menu | If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |
Dispatch onPrepareOptionsMenu() to fragments.
featureId | The panel that is being displayed. |
---|---|
view | The View that was returned by onCreatePanelView(). |
menu | If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |
Use this instead of
onRetainNonConfigurationInstance()
.
Retrieve later with
getLastCustomNonConfigurationInstance()
.
This method is deprecated.
Use the new
Fragment
API
setRetainInstance(boolean)
instead; this is also
available on older platforms through the Android compatibility package.
Retain all appropriate fragment and loader state. You can NOT
override this yourself! Use
onRetainCustomNonConfigurationInstance()
if you want to retain your own state.
Modifies the standard behavior to allow results to be delivered to fragments. This imposes a restriction that requestCode be <= 0xffff.
intent | The intent to start. |
---|---|
requestCode | If >= 0, this code will be returned in onActivityResult() when the activity exits. |
Called by Fragment.startActivityForResult() to implement its behavior.
Support library version of
invalidateOptionsMenu()
.
Invalidate the activity's options menu. This will cause relevant presentations of the menu to fully update via calls to onCreateOptionsMenu and onPrepareOptionsMenu the next time the menu is requested.
Dispatch incoming result to the correct fragment.
requestCode | The integer request code originally supplied to startActivityForResult(), allowing you to identify who this result came from. |
---|---|
resultCode | The integer result code returned by the child activity through its setResult(). |
data | An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). |
Perform initialization of all fragments and loaders.
savedInstanceState |
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.
|
---|
Destroy all fragments and loaders.
Handle onNewIntent() to inform the fragment manager that the state is not saved. If you are handling new intents and may be making changes to the fragment state, you want to be sure to call through to the super-class here first. Otherwise, if your state is saved but the activity is not stopped, you could get an onNewIntent() call which happens before onResume() and trying to perform fragment operations at that point will throw IllegalStateException because the fragment manager thinks the state is still saved.
intent | The new intent that was started for the activity. |
---|
Dispatch onPause() to fragments.
Dispatch onResume() to fragments.
Dispatch onResume() to fragments. Note that for better inter-operation
with older versions of the platform, at the point of this call the
fragments attached to the activity are
not
resumed. This means
that in some cases the previous state may still be saved, not allowing
fragment transactions that modify the state. To correctly interact
with fragments in their proper state, you should instead override
onResumeFragments()
.
This is the fragment-orientated version of
onResume()
that you
can override to perform operations in the Activity at the same point
where its fragments are resumed. Be sure to always call through to
the super-class.
Save all appropriate fragment state.
outState | Bundle in which to place your saved state. |
---|
Dispatch onStart() to all fragments. Ensure any created loaders are now started.
Dispatch onStop() to all fragments. Ensure all loaders are stopped.