Java android.app Activity fields, constructors, methods, implement or subclass

Example usage for Java android.app Activity fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.app Activity.

The text is from its open source code.

Subclass

android.app.Activity has subclasses.
Click this link to see all its subclasses.

Field

intRESULT_CANCELED
Standard activity result: operation canceled.
intRESULT_OK
Standard activity result: operation succeeded.
intRESULT_FIRST_USER
Start of user-defined activity results.
StringFRAGMENTS_TAG
intDEFAULT_KEYS_DIALER
Use with #setDefaultKeyMode to launch the dialer during default key handling.
intDEFAULT_KEYS_SHORTCUT
Use with #setDefaultKeyMode to execute a menu shortcut in default key handling.
intDEFAULT_KEYS_SEARCH_LOCAL
Use with #setDefaultKeyMode to specify that unhandled keystrokes will start an application-defined search.

Constructor

Method

voidaddContentView(View view, ViewGroup.LayoutParams params)
Add an additional content view to the activity.
booleanbindService(Intent service, ServiceConnection conn, int flags)
intcheckCallingOrSelfPermission(String permission)
intcheckSelfPermission(String permission)
ContextcreatePackageContext(String packageName, int flags)
booleandeleteDatabase(String name)
booleandeleteFile(String name)
voiddismissDialog(int id)
Dismiss a dialog that was previously shown via #showDialog(int) .
booleandispatchKeyEvent(KeyEvent event)
Called to process key events.
booleandispatchTouchEvent(MotionEvent ev)
Called to process touch screen events.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
String[]fileList()
TfindViewById(@IdRes int id)
Finds a view that was identified by the android:id XML attribute that was processed in #onCreate .
voidfinish()
Call this when your activity is done and should be closed.
voidfinishActivityFromChild(@NonNull Activity child, int requestCode)
This is called when a child activity of this one calls its finishActivity().
voidfinishAffinity()
Finish this activity as well as all activities immediately below it in the current task that have the same affinity.
voidfinishAfterTransition()
Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.
ActionBargetActionBar()
Retrieve a reference to this activity's ActionBar.
ApplicationgetApplication()
Return the application that owns this activity.
ContextgetApplicationContext()
ApplicationInfogetApplicationInfo()
AssetManagergetAssets()
ContextgetBaseContext()
FilegetCacheDir()
ComponentNamegetCallingActivity()
Return the name of the activity that invoked this activity.
intgetChangingConfigurations()
If this activity is being destroyed because it can not handle a configuration parameter being changed (and thus its #onConfigurationChanged(Configuration) method is not being called), then you can use this method to discover the set of changes that have occurred while in the process of being destroyed.
ClassgetClass()
Returns the runtime class of this Object .
ClassLoadergetClassLoader()
ComponentNamegetComponentName()
Returns the complete component name of this activity.
ContentResolvergetContentResolver()
ViewgetCurrentFocus()
Calls android.view.Window#getCurrentFocus on the Window of this Activity to return the currently focused view.
FilegetDir(String name, int mode)
DrawablegetDrawable(@DrawableRes int id)
Returns a drawable object associated with a particular resource ID and styled for the current theme.
FilegetExternalFilesDir(String type)
FilegetFilesDir()
FilegetFileStreamPath(String name)
FragmentManagergetFragmentManager()
Return the FragmentManager for interacting with fragments associated with this activity.
IntentgetIntent()
Return the intent that started this activity.
ObjectgetLastNonConfigurationInstance()
Retrieve the non-configuration instance data that was previously returned by #onRetainNonConfigurationInstance() .
LayoutInflatergetLayoutInflater()
Convenience for calling android.view.Window#getLayoutInflater .
LoaderManagergetLoaderManager()
Return the LoaderManager for this activity, creating it if needed.
StringgetLocalClassName()
Returns class name for this activity with the package prefix removed.
LoopergetMainLooper()
MediaControllergetMediaController()
Gets the controller which should be receiving media key and volume events while this activity is in the foreground.
MenuInflatergetMenuInflater()
Returns a MenuInflater with this context.
PackageManagergetPackageManager()
StringgetPackageName()
ActivitygetParent()
Return the parent activity if this view is an embedded child.
IntentgetParentActivityIntent()
Obtain an Intent that will launch an explicit target activity specified by this activity's logical parent.
SharedPreferencesgetPreferences(@Context.PreferencesMode int mode)
Retrieve a SharedPreferences object for accessing preferences that are private to this activity.
intgetRequestedOrientation()
Return the current requested orientation of the activity.
ResourcesgetResources()
SharedPreferencesgetSharedPreferences(String name, int mode)
StringgetString(@StringRes int resId)
Returns a localized string from the application's package's default string table.
StringgetString(@StringRes int resId, Object... formatArgs)
Returns a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and java.lang.String#format .
ObjectgetSystemService(@ServiceName @NonNull String name)
intgetTaskId()
Return the identifier of the task this activity is in.
CharSequencegetText(@StringRes int resId)
Return a localized, styled CharSequence from the application's package's default string table.
Resources.ThemegetTheme()
CharSequencegetTitle()
WindowgetWindow()
Retrieve the current android.view.Window for the activity.
WindowManagergetWindowManager()
Retrieve the window manager for showing custom windows.
voidgrantUriPermission(String toPackage, Uri uri, int modeFlags)
inthashCode()
Returns a hash code value for the object.
booleanhasWindowFocus()
Returns true if this activity's main window currently has window focus.
voidinvalidateOptionsMenu()
Declare that the options menu has changed, so should be recreated.
booleanisChangingConfigurations()
Check to see whether this activity is in the process of being destroyed in order to be recreated with a new configuration.
booleanisDestroyed()
Returns true if the final #onDestroy() call has been made on the Activity, so this instance is now dead.
booleanisFinishing()
Check to see whether this activity is in the process of finishing, either because you called #finish on it or someone else has requested that it finished.
booleanisInMultiWindowMode()
Returns true if the activity is currently in multi-window mode.
booleanisTaskRoot()
Return whether this activity is the root of a task.
CursormanagedQuery(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
Wrapper around ContentResolver#query(android.net.Uri,String[],String,String[],String) that gives the resulting Cursor to call #startManagingCursor so that the activity will manage its lifecycle for you.
booleanmoveTaskToBack(boolean nonRoot)
Move the task containing this activity to the back of the activity stack.
booleannavigateUpTo(Intent upIntent)
Navigate from this activity to the activity specified by upIntent, finishing this activity in the process.
TypedArrayobtainStyledAttributes(@StyleableRes int[] attrs)
Retrieve styled attribute information in this Context's theme.
TypedArrayobtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs)
Retrieve styled attribute information in this Context's theme.
TypedArrayobtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes)
Retrieve styled attribute information in this Context's theme.
voidonBackPressed()
Called when the activity has detected the user's press of the back key.
voidonConfigurationChanged(Configuration newConfig)
Called by the system when the device configuration changes while your activity is running.
booleanonCreateOptionsMenu(Menu menu)
Initialize the contents of the Activity's standard options menu.
booleanonKeyDown(int keyCode, KeyEvent event)
Called when a key was pressed down and not handled by any of the views inside of the activity.
booleanonOptionsItemSelected(MenuItem item)
This hook is called whenever an item in your options menu is selected.
booleanonPrepareOptionsMenu(Menu menu)
Prepare the Screen's standard options menu to be displayed.
voidonRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
Callback for the result from requesting permissions.
booleanonSearchRequested()
voidopenContextMenu(View view)
Programmatically opens the context menu for a particular view .
FileInputStreamopenFileInput(String name)
FileOutputStreamopenFileOutput(String name, int mode)
voidoverridePendingTransition(int enterAnim, int exitAnim)
Call immediately after one of the flavors of #startActivity(Intent) or #finish to specify an explicit transition animation to perform next.
voidrecreate()
Cause this Activity to be recreated with a new instance.
voidregisterForContextMenu(View view)
Registers a context menu to be shown for the given view (multiple views can show the context menu).
IntentregisterReceiver(BroadcastReceiver receiver, IntentFilter filter)
voidremoveDialog(int id)
Removes any internal references to a dialog managed by this Activity.
voidrequestPermissions(@NonNull String[] permissions, int requestCode)
Requests permissions to be granted to this application.
booleanrequestWindowFeature(int featureId)
Enable extended window features.
voidrunOnUiThread(Runnable action)
Runs the specified action on the UI thread.
voidsendBroadcast(Intent intent)
voidsendOrderedBroadcast(Intent intent, String receiverPermission)
voidsetContentView(@LayoutRes int layoutResID)
Set the activity content from a layout resource.
voidsetContentView(View view)
Set the activity content to an explicit view.
voidsetIntent(Intent newIntent)
Change the intent returned by #getIntent .
voidsetProgress(int progress)
Sets the progress for the progress bars in the title.
voidsetProgressBarIndeterminate(boolean indeterminate)
Sets whether the horizontal progress bar in the title should be indeterminate (the circular is always indeterminate).
voidsetProgressBarIndeterminateVisibility(boolean visible)
Sets the visibility of the indeterminate progress bar in the title.
voidsetRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation)
Change the desired orientation of this activity.
voidsetResult(int resultCode)
Call this to set the result that your activity will return to its caller.
voidsetResult(int resultCode, Intent data)
Call this to set the result that your activity will return to its caller.
voidsetTaskDescription(ActivityManager.TaskDescription taskDescription)
Sets information describing the task with this activity for presentation inside the Recents System UI.
voidsetTheme(int resid)
voidsetTitle(CharSequence title)
Change the title associated with this activity.
voidsetTitle(int titleId)
Change the title associated with this activity.
voidsetVolumeControlStream(int streamType)
Suggests an audio stream whose volume should be changed by the hardware volume controls.
booleanshouldShowRequestPermissionRationale(@NonNull String permission)
Gets whether you should show UI with rationale for requesting a permission.
booleanshouldUpRecreateTask(Intent targetIntent)
Returns true if the app should recreate the task when navigating 'up' from this activity by using targetIntent.
voidshowDialog(int id)
Simple version of #showDialog(int,Bundle) that does not take any arguments.
ActionModestartActionMode(ActionMode.Callback callback)
Start an action mode of the default type ActionMode#TYPE_PRIMARY .
voidstartActivity(Intent intent)
Same as #startActivity(Intent,Bundle) with no options specified.
voidstartActivity(Intent intent, @Nullable Bundle options)
Launch a new activity.
voidstartActivityForResult(@RequiresPermission Intent intent, int requestCode)
Same as calling #startActivityForResult(Intent,int,Bundle) with no options.
voidstartActivityForResult(@RequiresPermission Intent intent, int requestCode, @Nullable Bundle options)
Launch an activity for which you would like a result when it finished.
booleanstartActivityIfNeeded(@RequiresPermission @NonNull Intent intent, int requestCode)
Same as calling #startActivityIfNeeded(Intent,int,Bundle) with no options.
voidstartIntentSenderForResult(IntentSender intent, int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
Same as calling #startIntentSenderForResult(IntentSender,int,Intent,int,int,int,Bundle) with no options.
voidstartManagingCursor(Cursor c)
This method allows the activity to take care of managing the given Cursor 's lifecycle for you based on the activity's lifecycle.
voidstartSearch(@Nullable String initialQuery, boolean selectInitialQuery, @Nullable Bundle appSearchData, boolean globalSearch)
This hook is called to launch the search UI.
ComponentNamestartService(Intent service)
voidstopLockTask()
Stop the current task from being locked.
voidstopManagingCursor(Cursor c)
Given a Cursor that was previously given to #startManagingCursor , stop the activity's management of that cursor.
booleanstopService(Intent name)
StringtoString()
voidunbindService(ServiceConnection conn)
voidunregisterReceiver(BroadcastReceiver receiver)