|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectActivity
android.support.v4.app.FragmentActivity
public class FragmentActivity
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.
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.
Constructor Summary | |
---|---|
FragmentActivity()
|
Method Summary | |
---|---|
void |
dump(java.lang.String prefix,
java.io.FileDescriptor fd,
java.io.PrintWriter writer,
java.lang.String[] args)
Print the Activity's state into the given stream. |
java.lang.Object |
getLastCustomNonConfigurationInstance()
Return the value previously returned from onRetainCustomNonConfigurationInstance() . |
FragmentManager |
getSupportFragmentManager()
Return the FragmentManager for interacting with fragments associated with this activity. |
LoaderManager |
getSupportLoaderManager()
Return the LoaderManager for this fragment, creating it if needed. |
protected void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
Dispatch incoming result to the correct fragment. |
void |
onAttachFragment(Fragment fragment)
Called when a fragment is attached to the activity. |
void |
onBackPressed()
Take care of popping the fragment back stack or finishing the activity as appropriate. |
void |
onConfigurationChanged(Configuration newConfig)
Dispatch configuration change to all fragments. |
protected void |
onCreate(Bundle savedInstanceState)
Perform initialization of all fragments and loaders. |
boolean |
onCreatePanelMenu(int featureId,
Menu menu)
Dispatch to Fragment.onCreateOptionsMenu(). |
View |
onCreateView(java.lang.String name,
Context context,
AttributeSet attrs)
Add support for inflating the <fragment> tag. |
protected void |
onDestroy()
Destroy all fragments and loaders. |
boolean |
onKeyDown(int keyCode,
KeyEvent event)
Take care of calling onBackPressed() for pre-Eclair platforms. |
void |
onLowMemory()
Dispatch onLowMemory() to all fragments. |
boolean |
onMenuItemSelected(int featureId,
MenuItem item)
Dispatch context and options menu to fragments. |
void |
onPanelClosed(int featureId,
Menu menu)
Call onOptionsMenuClosed() on fragments. |
protected void |
onPause()
Dispatch onPause() to fragments. |
protected void |
onPostResume()
Dispatch onResume() to fragments. |
boolean |
onPreparePanel(int featureId,
View view,
Menu menu)
Dispatch onPrepareOptionsMenu() to fragments. |
protected void |
onResume()
Dispatch onResume() to fragments. |
protected void |
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. |
java.lang.Object |
onRetainCustomNonConfigurationInstance()
Use this instead of onRetainNonConfigurationInstance() . |
java.lang.Object |
onRetainNonConfigurationInstance()
Retain all appropriate fragment and loader state. |
protected void |
onSaveInstanceState(Bundle outState)
Save all appropriate fragment state. |
protected void |
onStart()
Dispatch onStart() to all fragments. |
protected void |
onStop()
Dispatch onStop() to all fragments. |
void |
startActivityForResult(Intent intent,
int requestCode)
Modifies the standard behavior to allow results to be delivered to fragments. |
void |
startActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode)
Called by Fragment.startActivityForResult() to implement its behavior. |
void |
supportInvalidateOptionsMenu()
Invalidate the activity's options menu. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FragmentActivity()
Method Detail |
---|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
public void onBackPressed()
public void onConfigurationChanged(Configuration newConfig)
protected void onCreate(Bundle savedInstanceState)
public boolean onCreatePanelMenu(int featureId, Menu menu)
public View onCreateView(java.lang.String name, Context context, AttributeSet attrs)
protected void onDestroy()
public boolean onKeyDown(int keyCode, KeyEvent event)
public void onLowMemory()
public boolean onMenuItemSelected(int featureId, MenuItem item)
public void onPanelClosed(int featureId, Menu menu)
protected void onPause()
protected void onResume()
onResumeFragments()
.
protected void onPostResume()
protected void onResumeFragments()
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.
public boolean onPreparePanel(int featureId, View view, Menu menu)
public final java.lang.Object onRetainNonConfigurationInstance()
onRetainCustomNonConfigurationInstance()
if you want to retain your own state.
protected void onSaveInstanceState(Bundle outState)
protected void onStart()
protected void onStop()
public java.lang.Object onRetainCustomNonConfigurationInstance()
onRetainNonConfigurationInstance()
.
Retrieve later with getLastCustomNonConfigurationInstance()
.
public java.lang.Object getLastCustomNonConfigurationInstance()
onRetainCustomNonConfigurationInstance()
.
public void supportInvalidateOptionsMenu()
public void dump(java.lang.String prefix, java.io.FileDescriptor fd, java.io.PrintWriter writer, java.lang.String[] args)
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.public void onAttachFragment(Fragment fragment)
public FragmentManager getSupportFragmentManager()
public void startActivityForResult(Intent intent, int requestCode)
public void startActivityFromFragment(Fragment fragment, Intent intent, int requestCode)
public LoaderManager getSupportLoaderManager()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |