android.support.v4.app
Class FragmentActivity

java.lang.Object
  extended by Activity
      extended by android.support.v4.app.FragmentActivity

public class FragmentActivity
extends Activity

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:


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

FragmentActivity

public FragmentActivity()
Method Detail

onActivityResult

protected void onActivityResult(int requestCode,
                                int resultCode,
                                Intent data)
Dispatch incoming result to the correct fragment.


onBackPressed

public void onBackPressed()
Take care of popping the fragment back stack or finishing the activity as appropriate.


onConfigurationChanged

public void onConfigurationChanged(Configuration newConfig)
Dispatch configuration change to all fragments.


onCreate

protected void onCreate(Bundle savedInstanceState)
Perform initialization of all fragments and loaders.


onCreatePanelMenu

public boolean onCreatePanelMenu(int featureId,
                                 Menu menu)
Dispatch to Fragment.onCreateOptionsMenu().


onCreateView

public View onCreateView(java.lang.String name,
                         Context context,
                         AttributeSet attrs)
Add support for inflating the <fragment> tag.


onDestroy

protected void onDestroy()
Destroy all fragments and loaders.


onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Take care of calling onBackPressed() for pre-Eclair platforms.


onLowMemory

public void onLowMemory()
Dispatch onLowMemory() to all fragments.


onMenuItemSelected

public boolean onMenuItemSelected(int featureId,
                                  MenuItem item)
Dispatch context and options menu to fragments.


onPanelClosed

public void onPanelClosed(int featureId,
                          Menu menu)
Call onOptionsMenuClosed() on fragments.


onPause

protected void onPause()
Dispatch onPause() to fragments.


onResume

protected void onResume()
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().


onPostResume

protected void onPostResume()
Dispatch onResume() to fragments.


onResumeFragments

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. Be sure to always call through to the super-class.


onPreparePanel

public boolean onPreparePanel(int featureId,
                              View view,
                              Menu menu)
Dispatch onPrepareOptionsMenu() to fragments.


onRetainNonConfigurationInstance

public final java.lang.Object onRetainNonConfigurationInstance()
Retain all appropriate fragment and loader state. You can NOT override this yourself! Use onRetainCustomNonConfigurationInstance() if you want to retain your own state.


onSaveInstanceState

protected void onSaveInstanceState(Bundle outState)
Save all appropriate fragment state.


onStart

protected void onStart()
Dispatch onStart() to all fragments. Ensure any created loaders are now started.


onStop

protected void onStop()
Dispatch onStop() to all fragments. Ensure all loaders are stopped.


onRetainCustomNonConfigurationInstance

public java.lang.Object onRetainCustomNonConfigurationInstance()
Use this instead of onRetainNonConfigurationInstance(). Retrieve later with getLastCustomNonConfigurationInstance().


getLastCustomNonConfigurationInstance

public java.lang.Object getLastCustomNonConfigurationInstance()
Return the value previously returned from onRetainCustomNonConfigurationInstance().


supportInvalidateOptionsMenu

public void supportInvalidateOptionsMenu()
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.


dump

public 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. This gets invoked if you run "adb shell dumpsys activity ".

Parameters:
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.

onAttachFragment

public void onAttachFragment(Fragment fragment)
Called when a fragment is attached to the activity.


getSupportFragmentManager

public FragmentManager getSupportFragmentManager()
Return the FragmentManager for interacting with fragments associated with this activity.


startActivityForResult

public void startActivityForResult(Intent intent,
                                   int requestCode)
Modifies the standard behavior to allow results to be delivered to fragments. This imposes a restriction that requestCode be <= 0xffff.


startActivityFromFragment

public void startActivityFromFragment(Fragment fragment,
                                      Intent intent,
                                      int requestCode)
Called by Fragment.startActivityForResult() to implement its behavior.


getSupportLoaderManager

public LoaderManager getSupportLoaderManager()
Return the LoaderManager for this fragment, creating it if needed.