Example usage for Java android.app Activity fields, constructors, methods, implement or subclass
The text is from its open source code.
int | RESULT_CANCELED Standard activity result: operation canceled. |
int | RESULT_OK Standard activity result: operation succeeded. |
int | RESULT_FIRST_USER Start of user-defined activity results. |
String | FRAGMENTS_TAG |
int | DEFAULT_KEYS_DIALER Use with #setDefaultKeyMode to launch the dialer during default key handling. |
int | DEFAULT_KEYS_SHORTCUT Use with #setDefaultKeyMode to execute a menu shortcut in default key handling. |
int | DEFAULT_KEYS_SEARCH_LOCAL Use with #setDefaultKeyMode to specify that unhandled keystrokes will start an application-defined search. |
void | addContentView(View view, ViewGroup.LayoutParams params) Add an additional content view to the activity. |
boolean | bindService(Intent service, ServiceConnection conn, int flags) |
int | checkCallingOrSelfPermission(String permission) |
int | checkSelfPermission(String permission) |
Context | createPackageContext(String packageName, int flags) |
boolean | deleteDatabase(String name) |
boolean | deleteFile(String name) |
void | dismissDialog(int id) Dismiss a dialog that was previously shown via #showDialog(int) . |
boolean | dispatchKeyEvent(KeyEvent event) Called to process key events. |
boolean | dispatchTouchEvent(MotionEvent ev) Called to process touch screen events. |
boolean | equals(Object obj) Indicates whether some other object is "equal to" this one. |
String[] | fileList() |
T | findViewById(@IdRes int id) Finds a view that was identified by the android:id XML attribute that was processed in #onCreate . |
void | finish() Call this when your activity is done and should be closed. |
void | finishActivityFromChild(@NonNull Activity child, int requestCode) This is called when a child activity of this one calls its finishActivity(). |
void | finishAffinity() Finish this activity as well as all activities immediately below it in the current task that have the same affinity. |
void | finishAfterTransition() Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition. |
ActionBar | getActionBar() Retrieve a reference to this activity's ActionBar. |
Application | getApplication() Return the application that owns this activity. |
Context | getApplicationContext() |
ApplicationInfo | getApplicationInfo() |
AssetManager | getAssets() |
Context | getBaseContext() |
File | getCacheDir() |
ComponentName | getCallingActivity() Return the name of the activity that invoked this activity. |
int | getChangingConfigurations() 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. |
Class> | getClass() Returns the runtime class of this Object . |
ClassLoader | getClassLoader() |
ComponentName | getComponentName() Returns the complete component name of this activity. |
ContentResolver | getContentResolver() |
View | getCurrentFocus() Calls android.view.Window#getCurrentFocus on the Window of this Activity to return the currently focused view. |
File | getDir(String name, int mode) |
Drawable | getDrawable(@DrawableRes int id) Returns a drawable object associated with a particular resource ID and styled for the current theme. |
File | getExternalFilesDir(String type) |
File | getFilesDir() |
File | getFileStreamPath(String name) |
FragmentManager | getFragmentManager() Return the FragmentManager for interacting with fragments associated with this activity. |
Intent | getIntent() Return the intent that started this activity. |
Object | getLastNonConfigurationInstance() Retrieve the non-configuration instance data that was previously returned by #onRetainNonConfigurationInstance() . |
LayoutInflater | getLayoutInflater() Convenience for calling android.view.Window#getLayoutInflater . |
LoaderManager | getLoaderManager() Return the LoaderManager for this activity, creating it if needed. |
String | getLocalClassName() Returns class name for this activity with the package prefix removed. |
Looper | getMainLooper() |
MediaController | getMediaController() Gets the controller which should be receiving media key and volume events while this activity is in the foreground. |
MenuInflater | getMenuInflater() Returns a MenuInflater with this context. |
PackageManager | getPackageManager() |
String | getPackageName() |
Activity | getParent() Return the parent activity if this view is an embedded child. |
Intent | getParentActivityIntent() Obtain an Intent that will launch an explicit target activity specified by this activity's logical parent. |
SharedPreferences | getPreferences(@Context.PreferencesMode int mode) Retrieve a SharedPreferences object for accessing preferences that are private to this activity. |
int | getRequestedOrientation() Return the current requested orientation of the activity. |
Resources | getResources() |
SharedPreferences | getSharedPreferences(String name, int mode) |
String | getString(@StringRes int resId) Returns a localized string from the application's package's default string table. |
String | getString(@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 . |
Object | getSystemService(@ServiceName @NonNull String name) |
int | getTaskId() Return the identifier of the task this activity is in. |
CharSequence | getText(@StringRes int resId) Return a localized, styled CharSequence from the application's package's default string table. |
Resources.Theme | getTheme() |
CharSequence | getTitle() |
Window | getWindow() Retrieve the current android.view.Window for the activity. |
WindowManager | getWindowManager() Retrieve the window manager for showing custom windows. |
void | grantUriPermission(String toPackage, Uri uri, int modeFlags) |
int | hashCode() Returns a hash code value for the object. |
boolean | hasWindowFocus() Returns true if this activity's main window currently has window focus. |
void | invalidateOptionsMenu() Declare that the options menu has changed, so should be recreated. |
boolean | isChangingConfigurations() Check to see whether this activity is in the process of being destroyed in order to be recreated with a new configuration. |
boolean | isDestroyed() Returns true if the final #onDestroy() call has been made on the Activity, so this instance is now dead. |
boolean | isFinishing() 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. |
boolean | isInMultiWindowMode() Returns true if the activity is currently in multi-window mode. |
boolean | isTaskRoot() Return whether this activity is the root of a task. |
Cursor | managedQuery(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. |
boolean | moveTaskToBack(boolean nonRoot) Move the task containing this activity to the back of the activity stack. |
boolean | navigateUpTo(Intent upIntent) Navigate from this activity to the activity specified by upIntent, finishing this activity in the process. |
TypedArray | obtainStyledAttributes(@StyleableRes int[] attrs) Retrieve styled attribute information in this Context's theme. |
TypedArray | obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) Retrieve styled attribute information in this Context's theme. |
TypedArray | obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) Retrieve styled attribute information in this Context's theme. |
void | onBackPressed() Called when the activity has detected the user's press of the back key. |
void | onConfigurationChanged(Configuration newConfig) Called by the system when the device configuration changes while your activity is running. |
boolean | onCreateOptionsMenu(Menu menu) Initialize the contents of the Activity's standard options menu. |
boolean | onKeyDown(int keyCode, KeyEvent event) Called when a key was pressed down and not handled by any of the views inside of the activity. |
boolean | onOptionsItemSelected(MenuItem item) This hook is called whenever an item in your options menu is selected. |
boolean | onPrepareOptionsMenu(Menu menu) Prepare the Screen's standard options menu to be displayed. |
void | onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) Callback for the result from requesting permissions. |
boolean | onSearchRequested() |
void | openContextMenu(View view) Programmatically opens the context menu for a particular view . |
FileInputStream | openFileInput(String name) |
FileOutputStream | openFileOutput(String name, int mode) |
void | overridePendingTransition(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. |
void | recreate() Cause this Activity to be recreated with a new instance. |
void | registerForContextMenu(View view) Registers a context menu to be shown for the given view (multiple views can show the context menu). |
Intent | registerReceiver(BroadcastReceiver receiver, IntentFilter filter) |
void | removeDialog(int id) Removes any internal references to a dialog managed by this Activity. |
void | requestPermissions(@NonNull String[] permissions, int requestCode) Requests permissions to be granted to this application. |
boolean | requestWindowFeature(int featureId) Enable extended window features. |
void | runOnUiThread(Runnable action) Runs the specified action on the UI thread. |
void | sendBroadcast(Intent intent) |
void | sendOrderedBroadcast(Intent intent, String receiverPermission) |
void | setContentView(@LayoutRes int layoutResID) Set the activity content from a layout resource. |
void | setContentView(View view) Set the activity content to an explicit view. |
void | setIntent(Intent newIntent) Change the intent returned by #getIntent . |
void | setProgress(int progress) Sets the progress for the progress bars in the title. |
void | setProgressBarIndeterminate(boolean indeterminate) Sets whether the horizontal progress bar in the title should be indeterminate (the circular is always indeterminate). |
void | setProgressBarIndeterminateVisibility(boolean visible) Sets the visibility of the indeterminate progress bar in the title. |
void | setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) Change the desired orientation of this activity. |
void | setResult(int resultCode) Call this to set the result that your activity will return to its caller. |
void | setResult(int resultCode, Intent data) Call this to set the result that your activity will return to its caller. |
void | setTaskDescription(ActivityManager.TaskDescription taskDescription) Sets information describing the task with this activity for presentation inside the Recents System UI. |
void | setTheme(int resid) |
void | setTitle(CharSequence title) Change the title associated with this activity. |
void | setTitle(int titleId) Change the title associated with this activity. |
void | setVolumeControlStream(int streamType) Suggests an audio stream whose volume should be changed by the hardware volume controls. |
boolean | shouldShowRequestPermissionRationale(@NonNull String permission) Gets whether you should show UI with rationale for requesting a permission. |
boolean | shouldUpRecreateTask(Intent targetIntent) Returns true if the app should recreate the task when navigating 'up' from this activity by using targetIntent. |
void | showDialog(int id) Simple version of #showDialog(int,Bundle) that does not take any arguments. |
ActionMode | startActionMode(ActionMode.Callback callback) Start an action mode of the default type ActionMode#TYPE_PRIMARY . |
void | startActivity(Intent intent) Same as #startActivity(Intent,Bundle) with no options specified. |
void | startActivity(Intent intent, @Nullable Bundle options) Launch a new activity. |
void | startActivityForResult(@RequiresPermission Intent intent, int requestCode) Same as calling #startActivityForResult(Intent,int,Bundle) with no options. |
void | startActivityForResult(@RequiresPermission Intent intent, int requestCode, @Nullable Bundle options) Launch an activity for which you would like a result when it finished. |
boolean | startActivityIfNeeded(@RequiresPermission @NonNull Intent intent, int requestCode) Same as calling #startActivityIfNeeded(Intent,int,Bundle) with no options. |
void | startIntentSenderForResult(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. |
void | startManagingCursor(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. |
void | startSearch(@Nullable String initialQuery, boolean selectInitialQuery, @Nullable Bundle appSearchData, boolean globalSearch) This hook is called to launch the search UI. |
ComponentName | startService(Intent service) |
void | stopLockTask() Stop the current task from being locked. |
void | stopManagingCursor(Cursor c) Given a Cursor that was previously given to #startManagingCursor , stop the activity's management of that cursor. |
boolean | stopService(Intent name) |
String | toString() |
void | unbindService(ServiceConnection conn) |
void | unregisterReceiver(BroadcastReceiver receiver) |