public class FragmentActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback, ActivityCompatApi23.RequestPermissionsRequestCodeValidator
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.
Activity.TranslucentConversionListener
Context.BindServiceFlags, Context.CreatePackageOptions, Context.ServiceName
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, DONT_FINISH_TASK_WITH_ACTIVITY, FINISH_TASK_WITH_ACTIVITY, FINISH_TASK_WITH_ROOT_ACTIVITY, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SOUND_TRIGGER_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, WALLPAPER_SERVICE, WIFI_NAN_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
FragmentActivity() |
Modifier and Type | Method and Description |
---|---|
void |
dump(String prefix,
FileDescriptor fd,
PrintWriter writer,
String[] args)
Print the Activity's state into the given stream.
|
Object |
getLastCustomNonConfigurationInstance()
Return the value previously returned from
onRetainCustomNonConfigurationInstance() . |
FragmentManager |
getSupportFragmentManager()
Return the FragmentManager for interacting with fragments associated
with this activity.
|
LoaderManager |
getSupportLoaderManager() |
MediaControllerCompat |
getSupportMediaController()
Retrieves the current
MediaControllerCompat for sending media key and volume events. |
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(String name,
Context context,
AttributeSet attrs)
Standard implementation of
LayoutInflater.Factory.onCreateView(java.lang.String, android.content.Context, android.util.AttributeSet) used when
inflating with the LayoutInflater returned by Activity.getSystemService(java.lang.String) . |
View |
onCreateView(View parent,
String name,
Context context,
AttributeSet attrs)
Standard implementation of
LayoutInflater.Factory2.onCreateView(View, String, Context, AttributeSet)
used when inflating with the LayoutInflater returned by Activity.getSystemService(java.lang.String) . |
protected void |
onDestroy()
Destroy all fragments and loaders.
|
void |
onLowMemory()
Dispatch onLowMemory() to all fragments.
|
boolean |
onMenuItemSelected(int featureId,
MenuItem item)
Dispatch context and options menu to fragments.
|
void |
onMultiWindowModeChanged(boolean isInMultiWindowMode)
Called by the system when the activity changes from fullscreen mode to multi-window mode and
visa-versa.
|
protected void |
onNewIntent(Intent intent)
Handle onNewIntent() to inform the fragment manager that the
state is not saved.
|
void |
onPanelClosed(int featureId,
Menu menu)
Call onOptionsMenuClosed() on fragments.
|
protected void |
onPause()
Dispatch onPause() to fragments.
|
void |
onPictureInPictureModeChanged(boolean isInPictureInPictureMode)
Called by the system when the activity changes to and from picture-in-picture mode.
|
protected void |
onPostResume()
Dispatch onResume() to fragments.
|
protected boolean |
onPrepareOptionsPanel(View view,
Menu menu) |
boolean |
onPreparePanel(int featureId,
View view,
Menu menu)
Dispatch onPrepareOptionsMenu() to fragments.
|
void |
onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults)
Callback for the result from requesting permissions.
|
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. |
Object |
onRetainCustomNonConfigurationInstance()
Use this instead of
onRetainNonConfigurationInstance() . |
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.
|
void |
onStateNotSaved()
Hook in to note that fragment state is no longer saved.
|
protected void |
onStop()
Dispatch onStop() to all fragments.
|
void |
setEnterSharedElementCallback(SharedElementCallback callback)
When
ActivityOptions.makeSceneTransitionAnimation(Activity,
android.view.View, String) was used to start an Activity, callback
will be called to handle shared elements on the launched Activity. |
void |
setExitSharedElementCallback(SharedElementCallback listener)
When
ActivityOptions.makeSceneTransitionAnimation(Activity,
android.view.View, String) was used to start an Activity, listener
will be called to handle shared elements on the launching Activity. |
void |
setSupportMediaController(MediaControllerCompat mediaController)
Sets a
MediaControllerCompat for later retrieval via
getSupportMediaController() . |
void |
startActivityForResult(Intent intent,
int requestCode)
Modifies the standard behavior to allow results to be delivered to fragments.
|
void |
startActivityForResult(Intent intent,
int requestCode,
Bundle options)
Launch an activity for which you would like a result when it finished.
|
void |
startActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode)
Called by Fragment.startActivityForResult() to implement its behavior.
|
void |
startActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode,
Bundle options)
Called by Fragment.startActivityForResult() to implement its behavior.
|
void |
startIntentSenderForResult(IntentSender intent,
int requestCode,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags)
Same as calling
Activity.startIntentSenderForResult(IntentSender, int,
Intent, int, int, int, Bundle) with no options. |
void |
startIntentSenderForResult(IntentSender intent,
int requestCode,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
Bundle options)
Like
Activity.startActivityForResult(Intent, int) , but allowing you
to use a IntentSender to describe the activity to be started. |
void |
startIntentSenderFromFragment(Fragment fragment,
IntentSender intent,
int requestCode,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
Bundle options)
Called by Fragment.startIntentSenderForResult() to implement its behavior.
|
void |
supportFinishAfterTransition()
Reverses the Activity Scene entry Transition and triggers the calling Activity
to reverse its exit Transition.
|
void |
supportInvalidateOptionsMenu()
Support library version of
Activity.invalidateOptionsMenu() . |
void |
supportPostponeEnterTransition()
Support library version of
Activity.postponeEnterTransition() that works
only on API 21 and later. |
void |
supportStartPostponedEnterTransition()
Support library version of
Activity.startPostponedEnterTransition()
that only works with API 21 and later. |
void |
validateRequestPermissionsRequestCode(int requestCode) |
addContentView, canStartActivityForResult, closeContextMenu, closeOptionsMenu, convertFromTranslucent, convertToTranslucent, createPendingResult, dismissDialog, dismissKeyboardShortcutsHelper, dispatchEnterAnimationComplete, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, enterPictureInPictureMode, enterPictureInPictureModeIfPossible, exitFreeformMode, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishAfterTransition, finishAndRemoveTask, finishFromChild, getActionBar, getActivityToken, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getContentScene, getContentTransitionManager, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMediaController, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getReferrer, getRequestedOrientation, getSearchEvent, getSystemService, getTaskId, getTitle, getTitleColor, getVoiceInteractor, getVolumeControlStream, getWindow, getWindowManager, getWindowStackId, hasWindowFocus, invalidateOptionsMenu, isBackgroundVisibleBehind, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isInMultiWindowMode, isInPictureInPictureMode, isLocalVoiceInteractionSupported, isOverlayWithDecorCaptionEnabled, isResumed, isTaskRoot, isVoiceInteraction, isVoiceInteractionRoot, managedQuery, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityReenter, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackgroundVisibleBehindChanged, onChildTitleChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelView, onCreateThumbnail, onDetachedFromWindow, onEnterAnimationComplete, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLocalVoiceInteractionStarted, onLocalVoiceInteractionStopped, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewActivityOptions, onOptionsItemSelected, onOptionsMenuClosed, onPostCreate, onPostCreate, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onProvideAssistContent, onProvideAssistData, onProvideKeyboardShortcuts, onProvideReferrer, onRestart, onRestoreInstanceState, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onVisibleBehindCanceled, onWindowAttributesChanged, onWindowDismissed, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, postponeEnterTransition, recreate, registerForContextMenu, releaseInstance, removeDialog, reportFullyDrawn, requestDragAndDropPermissions, requestPermissions, requestShowKeyboardShortcuts, requestVisibleBehind, requestWindowFeature, runOnUiThread, setActionBar, setContentTransitionManager, setContentView, setContentView, setContentView, setDefaultKeyMode, setEnterSharedElementCallback, setExitSharedElementCallback, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setMediaController, setOverlayWithDecorCaptionEnabled, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTaskDescription, setTheme, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, setVrModeEnabled, shouldShowRequestPermissionRationale, shouldUpRecreateTask, showAssist, showDialog, showDialog, showLockTaskEscapeMessage, startActionMode, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityAsCaller, startActivityAsUser, startActivityAsUser, startActivityForResult, startActivityForResultAsUser, startActivityForResultAsUser, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderFromChild, startIntentSenderFromChild, startIntentSenderFromChildFragment, startLocalVoiceInteraction, startLockTask, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startPostponedEnterTransition, startSearch, stopLocalVoiceInteraction, stopLockTask, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
applyOverrideConfiguration, attachBaseContext, getAssets, getOverrideConfiguration, getResources, getTheme, getThemeResId
bindService, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemServiceName, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startActivitiesAsUser, startInstrumentation, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
bindServiceAsUser, createCredentialEncryptedStorageContext, createDeviceEncryptedStorageContext, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, isCredentialEncryptedStorage, isDeviceEncryptedStorage, migrateDatabaseFrom, migrateSharedPreferencesFrom, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
protected void onActivityResult(int requestCode, int resultCode, Intent data)
onActivityResult
in class Activity
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").Activity.startActivityForResult(android.content.Intent, int)
,
Activity.createPendingResult(int, android.content.Intent, int)
,
Activity.setResult(int)
public void onBackPressed()
onBackPressed
in class Activity
public final void setSupportMediaController(MediaControllerCompat mediaController)
MediaControllerCompat
for later retrieval via
getSupportMediaController()
.
On API 21 and later, this controller will be tied to the window of the activity and
media key and volume events which are received while the Activity is in the foreground
will be forwarded to the controller and used to invoke transport controls or adjust the
volume. Prior to API 21, the global handling of media key and volume events through an
active MediaSessionCompat
and media button receiver
will still be respected.
mediaController
- The controller for the session which should receive
media keys and volume changes on API 21 and later.getSupportMediaController()
,
Activity.setMediaController(android.media.session.MediaController)
public final MediaControllerCompat getSupportMediaController()
MediaControllerCompat
for sending media key and volume events.setSupportMediaController(MediaControllerCompat)
,
Activity.getMediaController()
public void supportFinishAfterTransition()
Activity.finish()
is called. If no entry Transition was used, finish() is called
immediately and the Activity exit Transition is run.
On Android 4.4 or lower, this method only finishes the Activity with no special exit transition.
public void setEnterSharedElementCallback(SharedElementCallback callback)
ActivityOptions.makeSceneTransitionAnimation(Activity,
android.view.View, String)
was used to start an Activity, callback
will be called to handle shared elements on the launched Activity. This requires
Window.FEATURE_CONTENT_TRANSITIONS
.callback
- Used to manipulate shared element transitions on the launched Activity.public void setExitSharedElementCallback(SharedElementCallback listener)
ActivityOptions.makeSceneTransitionAnimation(Activity,
android.view.View, String)
was used to start an Activity, listener
will be called to handle shared elements on the launching Activity. Most
calls will only come when returning from the started Activity.
This requires Window.FEATURE_CONTENT_TRANSITIONS
.listener
- Used to manipulate shared element transitions on the launching Activity.public void supportPostponeEnterTransition()
Activity.postponeEnterTransition()
that works
only on API 21 and later.public void supportStartPostponedEnterTransition()
Activity.startPostponedEnterTransition()
that only works with API 21 and later.@CallSuper public void onMultiWindowModeChanged(boolean isInMultiWindowMode)
Note: If you override this method you must call
super.onMultiWindowModeChanged
to correctly dispatch the event
to support fragments attached to this activity.
onMultiWindowModeChanged
in class Activity
isInMultiWindowMode
- True if the activity is in multi-window mode.android.R.attr#resizeableActivity
@CallSuper public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode)
Note: If you override this method you must call
super.onPictureInPictureModeChanged
to correctly dispatch the event
to support fragments attached to this activity.
onPictureInPictureModeChanged
in class Activity
isInPictureInPictureMode
- True if the activity is in picture-in-picture mode.android.R.attr#supportsPictureInPicture
public void onConfigurationChanged(Configuration newConfig)
onConfigurationChanged
in interface ComponentCallbacks
onConfigurationChanged
in class Activity
newConfig
- The new device configuration.protected void onCreate(@Nullable Bundle savedInstanceState)
savedInstanceState
- If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Activity.onSaveInstanceState(android.os.Bundle)
. Note: Otherwise it is null.Activity.onStart()
,
Activity.onSaveInstanceState(android.os.Bundle)
,
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onPostCreate(android.os.Bundle)
public boolean onCreatePanelMenu(int featureId, Menu menu)
onCreatePanelMenu
in interface Window.Callback
onCreatePanelMenu
in class Activity
featureId
- The panel being created.menu
- The menu inside the panel.protected void onDestroy()
onDestroy
in class Activity
Activity.onPause()
,
Activity.onStop()
,
Activity.finish(int)
,
Activity.isFinishing()
public void onLowMemory()
onLowMemory
in interface ComponentCallbacks
onLowMemory
in class Activity
public boolean onMenuItemSelected(int featureId, MenuItem item)
onMenuItemSelected
in interface Window.Callback
onMenuItemSelected
in class Activity
featureId
- The panel that the menu is in.item
- The menu item that was selected.public void onPanelClosed(int featureId, Menu menu)
onPanelClosed
in interface Window.Callback
onPanelClosed
in class Activity
featureId
- The panel that is being displayed.menu
- If onCreatePanelView() returned null, this is the Menu
being displayed in the panel.protected void onPause()
onPause
in class Activity
Activity.onResume()
,
Activity.onSaveInstanceState(android.os.Bundle)
,
Activity.onStop()
protected void onNewIntent(Intent intent)
onNewIntent
in class Activity
intent
- The new intent that was started for the activity.Activity.getIntent()
,
Activity.setIntent(android.content.Intent)
,
Activity.onResume()
public void onStateNotSaved()
onStateNotSaved
in class Activity
protected void onResume()
onResumeFragments()
.onResume
in class Activity
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onRestart()
,
Activity.onPostResume()
,
Activity.onPause()
protected void onPostResume()
onPostResume
in class Activity
Activity.onResume()
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)
onPreparePanel
in interface Window.Callback
onPreparePanel
in class Activity
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.Window.Callback.onCreatePanelView(int)
public final Object onRetainNonConfigurationInstance()
onRetainCustomNonConfigurationInstance()
if you want to retain your own state.onRetainNonConfigurationInstance
in class Activity
protected void onSaveInstanceState(Bundle outState)
onSaveInstanceState
in class Activity
outState
- Bundle in which to place your saved state.Activity.onCreate(android.os.Bundle)
,
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onPause()
protected void onStart()
onStart
in class Activity
Activity.onCreate(android.os.Bundle)
,
Activity.onStop()
,
Activity.onResume()
protected void onStop()
onStop
in class Activity
Activity.onRestart()
,
Activity.onResume()
,
Activity.onSaveInstanceState(android.os.Bundle)
,
Activity.onDestroy()
public Object onRetainCustomNonConfigurationInstance()
onRetainNonConfigurationInstance()
.
Retrieve later with getLastCustomNonConfigurationInstance()
.public Object getLastCustomNonConfigurationInstance()
onRetainCustomNonConfigurationInstance()
.public void supportInvalidateOptionsMenu()
Activity.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.
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
dump
in class 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.public void onAttachFragment(Fragment fragment)
This is called after the attached fragment's onAttach
and before
the attached fragment's onCreate
if the fragment has not yet had a previous
call to onCreate
.
public FragmentManager getSupportFragmentManager()
public LoaderManager getSupportLoaderManager()
public void startActivityForResult(Intent intent, int requestCode)
startActivityForResult
in class Activity
intent
- The intent to start.requestCode
- If >= 0, this code will be returned in
onActivityResult() when the activity exits.Activity.startActivity(android.content.Intent)
public final void validateRequestPermissionsRequestCode(int requestCode)
validateRequestPermissionsRequestCode
in interface ActivityCompatApi23.RequestPermissionsRequestCodeValidator
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
Activity.requestPermissions(String[], int)
.
Note: It is possible that the permissions request interaction with the user is interrupted. In this case you will receive empty permissions and results arrays which should be treated as a cancellation.
onRequestPermissionsResult
in interface ActivityCompat.OnRequestPermissionsResultCallback
onRequestPermissionsResult
in class Activity
requestCode
- The request code passed in Activity.requestPermissions(String[], int)
.permissions
- The requested permissions. Never null.grantResults
- The grant results for the corresponding permissions
which is either PackageManager.PERMISSION_GRANTED
or PackageManager.PERMISSION_DENIED
. Never null.Activity.requestPermissions(String[], int)
public void startActivityFromFragment(Fragment fragment, Intent intent, int requestCode)
public void startActivityFromFragment(Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options)
public void startIntentSenderFromFragment(Fragment fragment, IntentSender intent, int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException
IntentSender.SendIntentException
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options)
Activity
Activity.startActivity(android.content.Intent)
(the activity is not launched as a sub-activity).
Note that this method should only be used with Intent protocols
that are defined to return a result. In other protocols (such as
Intent.ACTION_MAIN
or Intent.ACTION_VIEW
), you may
not get the result when you expect. For example, if the activity you
are launching uses the singleTask launch mode, it will not run in your
task and thus you will immediately receive a cancel result.
As a special case, if you call startActivityForResult() with a requestCode >= 0 during the initial onCreate(Bundle savedInstanceState)/onResume() of your activity, then your window will not be displayed until a result is returned back from the started activity. This is to avoid visible flickering when redirecting to another activity.
This method throws ActivityNotFoundException
if there was no Activity found to run the given Intent.
startActivityForResult
in class Activity
intent
- The intent to start.requestCode
- If >= 0, this code will be returned in
onActivityResult() when the activity exits.options
- Additional options for how the Activity should be started.
See Context.startActivity(Intent, Bundle)
for more details.Activity.startActivity(android.content.Intent)
public void startIntentSenderForResult(IntentSender intent, int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException
Activity
Activity.startActivityForResult(Intent, int)
, but allowing you
to use a IntentSender to describe the activity to be started. If
the IntentSender is for an activity, that activity will be started
as if you had called the regular Activity.startActivityForResult(Intent, int)
here; otherwise, its associated action will be executed (such as
sending a broadcast) as if you had called
IntentSender.sendIntent
on it.startIntentSenderForResult
in class Activity
intent
- The IntentSender to launch.requestCode
- If >= 0, this code will be returned in
onActivityResult() when the activity exits.fillInIntent
- If non-null, this will be provided as the
intent parameter to IntentSender.sendIntent(android.content.Context, int, android.content.Intent, android.content.IntentSender.OnFinished, android.os.Handler)
.flagsMask
- Intent flags in the original IntentSender that you
would like to change.flagsValues
- Desired values for any bits set in
flagsMaskextraFlags
- Always set to 0.options
- Additional options for how the Activity should be started.
See Context.startActivity(Intent, Bundle)
for more details. If options
have also been supplied by the IntentSender, options given here will
override any that conflict with those given by the IntentSender.IntentSender.SendIntentException
public View onCreateView(View parent, String name, Context context, AttributeSet attrs)
Activity
LayoutInflater.Factory2.onCreateView(View, String, Context, AttributeSet)
used when inflating with the LayoutInflater returned by Activity.getSystemService(java.lang.String)
.
This implementation handles onCreateView
in interface LayoutInflater.Factory2
onCreateView
in class Activity
parent
- The parent that the created view will be placed
in; note that this may be null.name
- Tag name to be inflated.context
- The context the view is being created in.attrs
- Inflation attributes as specified in XML file.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet)
,
Window.getLayoutInflater()
public View onCreateView(String name, Context context, AttributeSet attrs)
Activity
LayoutInflater.Factory.onCreateView(java.lang.String, android.content.Context, android.util.AttributeSet)
used when
inflating with the LayoutInflater returned by Activity.getSystemService(java.lang.String)
.
This implementation does nothing and is for
pre-Build.VERSION_CODES.HONEYCOMB
apps. Newer apps
should use Activity.onCreateView(View, String, Context, AttributeSet)
.onCreateView
in interface LayoutInflater.Factory
onCreateView
in class Activity
name
- Tag name to be inflated.context
- The context the view is being created in.attrs
- Inflation attributes as specified in XML file.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet)
,
Window.getLayoutInflater()
public void startIntentSenderForResult(IntentSender intent, int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags) throws IntentSender.SendIntentException
Activity
Activity.startIntentSenderForResult(IntentSender, int,
Intent, int, int, int, Bundle)
with no options.startIntentSenderForResult
in class Activity
intent
- The IntentSender to launch.requestCode
- If >= 0, this code will be returned in
onActivityResult() when the activity exits.fillInIntent
- If non-null, this will be provided as the
intent parameter to IntentSender.sendIntent(android.content.Context, int, android.content.Intent, android.content.IntentSender.OnFinished, android.os.Handler)
.flagsMask
- Intent flags in the original IntentSender that you
would like to change.flagsValues
- Desired values for any bits set in
flagsMaskextraFlags
- Always set to 0.IntentSender.SendIntentException