public class AppCompatActivity extends FragmentActivity implements AppCompatCallback, TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider
You can add an ActionBar
to your activity when running on API level 7 or higher
by extending this class for your activity and setting the activity theme to
Theme.AppCompat
or a similar theme.
For information about how to use the action bar, including how to add action items, navigation modes and more, read the Action Bar API guide.
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 |
---|
AppCompatActivity() |
Modifier and Type | Method and Description |
---|---|
void |
addContentView(View view,
ViewGroup.LayoutParams params)
Add an additional content view to the activity.
|
boolean |
dispatchKeyEvent(KeyEvent event)
Called to process key events.
|
View |
findViewById(int id)
Finds a view that was identified by the id attribute from the XML that
was processed in
Activity.onCreate(android.os.Bundle) . |
AppCompatDelegate |
getDelegate() |
ActionBarDrawerToggle.Delegate |
getDrawerToggleDelegate() |
MenuInflater |
getMenuInflater()
Returns a
MenuInflater with this context. |
Resources |
getResources()
Returns a Resources instance for the application's package.
|
ActionBar |
getSupportActionBar()
Support library version of
Activity.getActionBar() . |
Intent |
getSupportParentActivityIntent()
Obtain an
Intent that will launch an explicit target activity
specified by sourceActivity's NavUtils.PARENT_ACTIVITY <meta-data>
element in the application's manifest. |
void |
invalidateOptionsMenu()
Declare that the options menu has changed, so should be recreated.
|
void |
onConfigurationChanged(Configuration newConfig)
Dispatch configuration change to all fragments.
|
void |
onContentChanged()
This hook is called whenever the content view of the screen changes
(due to a call to
Window.setContentView or
Window.addContentView ). |
protected void |
onCreate(Bundle savedInstanceState)
Perform initialization of all fragments and loaders.
|
void |
onCreateSupportNavigateUpTaskStack(TaskStackBuilder builder)
Support version of
Activity.onCreateNavigateUpTaskStack(android.app.TaskStackBuilder) . |
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.
|
boolean |
onMenuItemSelected(int featureId,
MenuItem item)
Dispatch context and options menu to fragments.
|
boolean |
onMenuOpened(int featureId,
Menu menu)
Called when a panel's menu is opened by the user.
|
void |
onPanelClosed(int featureId,
Menu menu)
Call onOptionsMenuClosed() on fragments.
|
protected void |
onPostCreate(Bundle savedInstanceState)
Called when activity start-up is complete (after
Activity.onStart()
and Activity.onRestoreInstanceState(android.os.Bundle) have been called). |
protected void |
onPostResume()
Dispatch onResume() to fragments.
|
void |
onPrepareSupportNavigateUpTaskStack(TaskStackBuilder builder)
Support version of
Activity.onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder) . |
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 |
onSupportActionModeFinished(ActionMode mode)
Notifies the activity that a support action mode has finished.
|
void |
onSupportActionModeStarted(ActionMode mode)
Notifies the Activity that a support action mode has been started.
|
void |
onSupportContentChanged()
Deprecated.
Use
onContentChanged() instead. |
boolean |
onSupportNavigateUp()
This method is called whenever the user chooses to navigate Up within your application's
activity hierarchy from the action bar.
|
protected void |
onTitleChanged(CharSequence title,
int color) |
ActionMode |
onWindowStartingSupportActionMode(ActionMode.Callback callback)
Called when a support action mode is being started for this window.
|
void |
setContentView(int layoutResID)
Set the activity content from a layout resource.
|
void |
setContentView(View view)
Set the activity content to an explicit view.
|
void |
setContentView(View view,
ViewGroup.LayoutParams params)
Set the activity content to an explicit view.
|
void |
setSupportActionBar(Toolbar toolbar)
|
void |
setSupportProgress(int progress)
Deprecated.
Progress bars are no longer provided in AppCompat.
|
void |
setSupportProgressBarIndeterminate(boolean indeterminate)
Deprecated.
Progress bars are no longer provided in AppCompat.
|
void |
setSupportProgressBarIndeterminateVisibility(boolean visible)
Deprecated.
Progress bars are no longer provided in AppCompat.
|
void |
setSupportProgressBarVisibility(boolean visible)
Deprecated.
Progress bars are no longer provided in AppCompat.
|
void |
setTheme(int resid)
Set the base theme for this context.
|
void |
startActivityForResult(Intent intent,
int requestCode,
Bundle options)
Launch an activity for which you would like a result when it finished.
|
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. |
ActionMode |
startSupportActionMode(ActionMode.Callback callback)
Start an action mode.
|
void |
supportInvalidateOptionsMenu()
Support library version of
Activity.invalidateOptionsMenu() . |
void |
supportNavigateUpTo(Intent upIntent)
Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity
in the process. upIntent will have the flag
Intent.FLAG_ACTIVITY_CLEAR_TOP set
by this method, along with any others required for proper up navigation as outlined
in the Android Design Guide. |
boolean |
supportRequestWindowFeature(int featureId)
Enable extended support library window features.
|
boolean |
supportShouldUpRecreateTask(Intent targetIntent)
Returns true if sourceActivity should recreate the task when navigating 'up'
by using targetIntent.
|
dump, getLastCustomNonConfigurationInstance, getSupportFragmentManager, getSupportLoaderManager, getSupportMediaController, onActivityResult, onAttachFragment, onBackPressed, onCreatePanelMenu, onLowMemory, onMultiWindowModeChanged, onNewIntent, onPause, onPictureInPictureModeChanged, onPrepareOptionsPanel, onPreparePanel, onRequestPermissionsResult, onResume, onResumeFragments, onRetainCustomNonConfigurationInstance, onRetainNonConfigurationInstance, onStateNotSaved, setEnterSharedElementCallback, setExitSharedElementCallback, setSupportMediaController, startActivityForResult, startActivityFromFragment, startActivityFromFragment, startIntentSenderFromFragment, supportFinishAfterTransition, supportPostponeEnterTransition, supportStartPostponedEnterTransition, validateRequestPermissionsRequestCode
canStartActivityForResult, closeContextMenu, closeOptionsMenu, convertFromTranslucent, convertToTranslucent, createPendingResult, dismissDialog, dismissKeyboardShortcutsHelper, dispatchEnterAnimationComplete, dispatchGenericMotionEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, enterPictureInPictureMode, enterPictureInPictureModeIfPossible, exitFreeformMode, finish, finishActivity, finishActivityFromChild, finishAffinity, finishAfterTransition, finishAndRemoveTask, finishFromChild, getActionBar, getActivityToken, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getContentScene, getContentTransitionManager, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMediaController, getParent, getParentActivityIntent, getPreferences, getReferrer, getRequestedOrientation, getSearchEvent, getSystemService, getTaskId, getTitle, getTitleColor, getVoiceInteractor, getVolumeControlStream, getWindow, getWindowManager, getWindowStackId, hasWindowFocus, 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, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelView, onCreateThumbnail, onDetachedFromWindow, onEnterAnimationComplete, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLocalVoiceInteractionStarted, onLocalVoiceInteractionStopped, onNavigateUp, onNavigateUpFromChild, onNewActivityOptions, onOptionsItemSelected, onOptionsMenuClosed, onPostCreate, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onProvideAssistContent, onProvideAssistData, onProvideKeyboardShortcuts, onProvideReferrer, onRestart, onRestoreInstanceState, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, 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, setDefaultKeyMode, setEnterSharedElementCallback, setExitSharedElementCallback, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setMediaController, setOverlayWithDecorCaptionEnabled, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTaskDescription, 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, 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 onCreate(@Nullable Bundle savedInstanceState)
FragmentActivity
onCreate
in class FragmentActivity
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 void setTheme(@StyleRes int resid)
Context
Activity.setContentView(int)
or
LayoutInflater.inflate(int, android.view.ViewGroup)
).protected void onPostCreate(@Nullable Bundle savedInstanceState)
Activity
Activity.onStart()
and Activity.onRestoreInstanceState(android.os.Bundle)
have been called). Applications will
generally not implement this method; it is intended for system
classes to do final initialization after application code has run.
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
onPostCreate
in class Activity
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.onCreate(android.os.Bundle)
@Nullable public ActionBar getSupportActionBar()
Activity.getActionBar()
.
Retrieve a reference to this activity's ActionBar.
public void setSupportActionBar(@Nullable Toolbar toolbar)
Toolbar
to act as the
ActionBar
for this Activity window.
When set to a non-null value the Activity.getActionBar()
method will return
an ActionBar
object that can be used to control the given
toolbar as if it were a traditional window decor action bar. The toolbar's menu will be
populated with the Activity's options menu and the navigation button will be wired through
the standard home
menu select action.
In order to use a Toolbar within the Activity's window content the application
must not request the window feature
FEATURE_SUPPORT_ACTION_BAR
.
toolbar
- Toolbar to set as the Activity's action bar, or null
to clear itpublic MenuInflater getMenuInflater()
Activity
MenuInflater
with this context.getMenuInflater
in class Activity
public void setContentView(@LayoutRes int layoutResID)
Activity
setContentView
in class Activity
layoutResID
- Resource ID to be inflated.Activity.setContentView(android.view.View)
,
Activity.setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
public void setContentView(View view)
Activity
ViewGroup.LayoutParams#MATCH_PARENT
. To use
your own layout parameters, invoke
Activity.setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
instead.setContentView
in class Activity
view
- The desired content to display.Activity.setContentView(int)
,
Activity.setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
public void setContentView(View view, ViewGroup.LayoutParams params)
Activity
setContentView
in class Activity
view
- The desired content to display.params
- Layout parameters for the view.Activity.setContentView(android.view.View)
,
Activity.setContentView(int)
public void addContentView(View view, ViewGroup.LayoutParams params)
Activity
addContentView
in class Activity
view
- The desired content to display.params
- Layout parameters for the view.public void onConfigurationChanged(Configuration newConfig)
FragmentActivity
onConfigurationChanged
in interface ComponentCallbacks
onConfigurationChanged
in class FragmentActivity
newConfig
- The new device configuration.protected void onPostResume()
FragmentActivity
onPostResume
in class FragmentActivity
Activity.onResume()
protected void onStart()
FragmentActivity
onStart
in class FragmentActivity
Activity.onCreate(android.os.Bundle)
,
Activity.onStop()
,
Activity.onResume()
protected void onStop()
FragmentActivity
onStop
in class FragmentActivity
Activity.onRestart()
,
Activity.onResume()
,
Activity.onSaveInstanceState(android.os.Bundle)
,
Activity.onDestroy()
public View findViewById(@IdRes int id)
Activity
Activity.onCreate(android.os.Bundle)
.findViewById
in class Activity
public final boolean onMenuItemSelected(int featureId, MenuItem item)
FragmentActivity
onMenuItemSelected
in interface Window.Callback
onMenuItemSelected
in class FragmentActivity
featureId
- The panel that the menu is in.item
- The menu item that was selected.protected void onDestroy()
FragmentActivity
onDestroy
in class FragmentActivity
Activity.onPause()
,
Activity.onStop()
,
Activity.finish(int)
,
Activity.isFinishing()
protected void onTitleChanged(CharSequence title, int color)
onTitleChanged
in class Activity
public boolean supportRequestWindowFeature(int featureId)
This is a convenience for calling
getWindow().requestFeature()
.
featureId
- The desired feature as defined in
Window
or WindowCompat
.Activity.requestWindowFeature(int)
,
Window.requestFeature(int)
public void supportInvalidateOptionsMenu()
FragmentActivity
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.
supportInvalidateOptionsMenu
in class FragmentActivity
public void invalidateOptionsMenu()
Activity
Activity.onCreateOptionsMenu(Menu)
method will be called the next
time it needs to be displayed.invalidateOptionsMenu
in class Activity
@CallSuper public void onSupportActionModeStarted(@NonNull ActionMode mode)
onSupportActionModeStarted
in interface AppCompatCallback
mode
- The new action mode.@CallSuper public void onSupportActionModeFinished(@NonNull ActionMode mode)
onSupportActionModeFinished
in interface AppCompatCallback
mode
- The action mode that just finished.@Nullable public ActionMode onWindowStartingSupportActionMode(@NonNull ActionMode.Callback callback)
onWindowStartingSupportActionMode
in interface AppCompatCallback
callback
- Callback to control the lifecycle of this action mode@Nullable public ActionMode startSupportActionMode(@NonNull ActionMode.Callback callback)
callback
- Callback that will manage lifecycle events for this context mode@Deprecated public void setSupportProgressBarVisibility(boolean visible)
@Deprecated public void setSupportProgressBarIndeterminateVisibility(boolean visible)
@Deprecated public void setSupportProgressBarIndeterminate(boolean indeterminate)
@Deprecated public void setSupportProgress(int progress)
public void onCreateSupportNavigateUpTaskStack(@NonNull TaskStackBuilder builder)
Activity.onCreateNavigateUpTaskStack(android.app.TaskStackBuilder)
.
This method will be called on all platform versions.
Define the synthetic task stack that will be generated during Up navigation from
a different task.
The default implementation of this method adds the parent chain of this activity
as specified in the manifest to the supplied TaskStackBuilder
. Applications
may choose to override this method to construct the desired task stack in a different
way.
This method will be invoked by the default implementation of Activity.onNavigateUp()
if Activity.shouldUpRecreateTask(android.content.Intent)
returns true when supplied with the intent
returned by Activity.getParentActivityIntent()
.
Applications that wish to supply extra Intent parameters to the parent stack defined
by the manifest should override
onPrepareSupportNavigateUpTaskStack(android.support.v4.app.TaskStackBuilder)
.
builder
- An empty TaskStackBuilder - the application should add intents representing
the desired task stackpublic void onPrepareSupportNavigateUpTaskStack(@NonNull TaskStackBuilder builder)
Activity.onPrepareNavigateUpTaskStack(android.app.TaskStackBuilder)
.
This method will be called on all platform versions.
Prepare the synthetic task stack that will be generated during Up navigation
from a different task.
This method receives the TaskStackBuilder
with the constructed series of
Intents as generated by onCreateSupportNavigateUpTaskStack(android.support.v4.app.TaskStackBuilder)
.
If any extra data should be added to these intents before launching the new task,
the application should override this method and add that data here.
builder
- A TaskStackBuilder that has been populated with Intents by
onCreateNavigateUpTaskStack.public boolean onSupportNavigateUp()
If a parent was specified in the manifest for this activity or an activity-alias to it,
default Up navigation will be handled automatically. See
getSupportParentActivityIntent()
for how to specify the parent. If any activity
along the parent chain requires extra Intent arguments, the Activity subclass
should override the method onPrepareSupportNavigateUpTaskStack(android.support.v4.app.TaskStackBuilder)
to supply those arguments.
See Tasks and Back Stack from the developer guide and Navigation from the design guide for more information about navigating within your app.
See the TaskStackBuilder
class and the Activity methods
getSupportParentActivityIntent()
, supportShouldUpRecreateTask(android.content.Intent)
, and
supportNavigateUpTo(android.content.Intent)
for help implementing custom Up navigation.
@Nullable public Intent getSupportParentActivityIntent()
Intent
that will launch an explicit target activity
specified by sourceActivity's NavUtils.PARENT_ACTIVITY
<meta-data>
element in the application's manifest. If the device is running
Jellybean or newer, the android:parentActivityName attribute will be preferred
if it is present.getSupportParentActivityIntent
in interface TaskStackBuilder.SupportParentable
public boolean supportShouldUpRecreateTask(@NonNull Intent targetIntent)
If this method returns false the app can trivially call
supportNavigateUpTo(android.content.Intent)
using the same parameters to correctly perform
up navigation. If this method returns false, the app should synthesize a new task stack
by using TaskStackBuilder
or another similar mechanism to perform up navigation.
targetIntent
- An intent representing the target destination for up navigationpublic void supportNavigateUpTo(@NonNull Intent upIntent)
Intent.FLAG_ACTIVITY_CLEAR_TOP
set
by this method, along with any others required for proper up navigation as outlined
in the Android Design Guide.
This method should be used when performing up navigation from within the same task
as the destination. If up navigation should cross tasks in some cases, see
supportShouldUpRecreateTask(android.content.Intent)
.
upIntent
- An intent representing the target destination for up navigationpublic void onContentChanged()
Window.Callback
Window.setContentView
or
Window.addContentView
).onContentChanged
in interface Window.Callback
onContentChanged
in class Activity
@Deprecated public void onSupportContentChanged()
onContentChanged()
instead.@Nullable public ActionBarDrawerToggle.Delegate getDrawerToggleDelegate()
getDrawerToggleDelegate
in interface ActionBarDrawerToggle.DelegateProvider
public boolean onMenuOpened(int featureId, Menu menu)
Please note: AppCompat uses it's own feature id for the action bar:
FEATURE_SUPPORT_ACTION_BAR
.
onMenuOpened
in interface Window.Callback
onMenuOpened
in class Activity
featureId
- The panel that the menu is in.menu
- The menu that is opened.public void onPanelClosed(int featureId, Menu menu)
Please note: AppCompat uses it's own feature id for the action bar:
FEATURE_SUPPORT_ACTION_BAR
.
onPanelClosed
in interface Window.Callback
onPanelClosed
in class FragmentActivity
featureId
- The panel that is being displayed.menu
- If onCreatePanelView() returned null, this is the Menu
being displayed in the panel.protected void onSaveInstanceState(Bundle outState)
FragmentActivity
onSaveInstanceState
in class FragmentActivity
outState
- Bundle in which to place your saved state.Activity.onCreate(android.os.Bundle)
,
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onPause()
@NonNull public AppCompatDelegate getDelegate()
AppCompatDelegate
being used by this Activity.public boolean dispatchKeyEvent(KeyEvent event)
Activity
dispatchKeyEvent
in interface Window.Callback
dispatchKeyEvent
in class Activity
event
- The key event.public Resources getResources()
Context
Note: Implementations of this method should return
a Resources instance that is consistent with the AssetManager instance
returned by Context.getAssets()
. For example, they should share the
same Configuration
object.
getResources
in class ContextThemeWrapper
Context.getAssets()
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