# ActivityCompat

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-v13:28.0.0-alpha1  
Deprecated since version 27.1.0  
Summary:[Protected Ctors](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#proctors)\|[Inherited Methods](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#)  

# ActivityCompat

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
ActivityCompat
`  
`


``


``

extends `[ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)`


``


`

|---|---|---|----------------------------------------|
| java.lang.Object                                ||||
| ↳ | [android.support.v4.content.ContextCompat](https://developer.android.com/reference/android/support/v4/content/ContextCompat) |||
|   | ↳ | [android.support.v4.app.ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat) ||
|   |   | ↳ | android.support.v13.app.ActivityCompat |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 27.1.0.**   
Use[android.support.v4.app.ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat).

Helper for accessing features in[Activity](https://developer.android.com/reference/android/app/Activity.html)in a backwards compatible fashion.

## Summary

|                                                                                                                                           ### Protected constructors                                                                                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ActivityCompat](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#ActivityCompat())`() ` *This constructor was deprecated in API level 27.1.0. Use[android.support.v4.app.ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat).* |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#)From class` `[android.support.v4.app.ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)` ` |-----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static void`                                                                                                                          | ` `[finishAffinity](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#finishAffinity(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) ` Finish this activity, and tries to finish all activities immediately below it in the current task that have the same affinity.                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` static void`                                                                                                                          | ` `[finishAfterTransition](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#finishAfterTransition(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) ` Reverses the Activity Scene entry Transition and triggers the calling Activity to reverse its exit Transition.                                                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` static `[Uri](https://developer.android.com/reference/android/net/Uri.html)                                                           | ` `[getReferrer](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#getReferrer(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) ` Return information about who launched this activity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ` static boolean`                                                                                                                       | ` `[invalidateOptionsMenu](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#invalidateOptionsMenu(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) ` *This method was deprecated in API level 27.1.0. Use[invalidateOptionsMenu()](https://developer.android.com/reference/android/app/Activity.html#invalidateOptionsMenu())directly.*                                                                                                                                                                                                                                                                                                                                                                                  | | ` static void`                                                                                                                          | ` `[postponeEnterTransition](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#postponeEnterTransition(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ` static `[DragAndDropPermissionsCompat](https://developer.android.com/reference/android/support/v13/view/DragAndDropPermissionsCompat) | ` `[requestDragAndDropPermissions](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#requestDragAndDropPermissions(android.app.Activity, android.view.DragEvent))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[DragEvent](https://developer.android.com/reference/android/view/DragEvent.html)` dragEvent) ` Create[DragAndDropPermissionsCompat](https://developer.android.com/reference/android/support/v13/view/DragAndDropPermissionsCompat)object bound to this activity and controlling the access permissions for content URIs associated with the[DragEvent](https://developer.android.com/reference/android/view/DragEvent.html).                                                                                                 | | ` static void`                                                                                                                          | ` `[requestPermissions](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#requestPermissions(android.app.Activity, java.lang.String[], int))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, String[] permissions, int requestCode) ` Requests permissions to be granted to this application.                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` static <T extends `[View](https://developer.android.com/reference/android/view/View.html)`> T`                                        | ` `[requireViewById](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#requireViewById(android.app.Activity, int))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, int id) ` Finds a view that was identified by the`android:id`XML attribute that was processed in[onCreate(Bundle)](https://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle)), or throws an IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.                                                                                                                                                                                                                                                | | ` static void`                                                                                                                          | ` `[setEnterSharedElementCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#setEnterSharedElementCallback(android.app.Activity, android.support.v4.app.SharedElementCallback))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)` callback) ` When[makeSceneTransitionAnimation(Activity, android.view.View, String)](https://developer.android.com/reference/android/app/ActivityOptions.html#makeSceneTransitionAnimation(android.app.Activity, android.view.View, java.lang.String))was used to start an Activity,<var translate="no">callback</var>will be called to handle shared elements on the*launched*Activity. | | ` static void`                                                                                                                          | ` `[setExitSharedElementCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#setExitSharedElementCallback(android.app.Activity, android.support.v4.app.SharedElementCallback))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)` callback) ` When[makeSceneTransitionAnimation(Activity, android.view.View, String)](https://developer.android.com/reference/android/app/ActivityOptions.html#makeSceneTransitionAnimation(android.app.Activity, android.view.View, java.lang.String))was used to start an Activity,<var translate="no">callback</var>will be called to handle shared elements on the*launching*Activity.  | | ` static void`                                                                                                                          | ` `[setPermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#setPermissionCompatDelegate(android.support.v4.app.ActivityCompat.PermissionCompatDelegate))`(`[ActivityCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.PermissionCompatDelegate)` delegate) ` Sets the permission delegate for`ActivityCompat`.                                                                                                                                                                                                                                                                                                                                                                                         | | ` static boolean`                                                                                                                       | ` `[shouldShowRequestPermissionRationale](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#shouldShowRequestPermissionRationale(android.app.Activity, java.lang.String))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, String permission) ` Gets whether you should show UI with rationale for requesting a permission.                                                                                                                                                                                                                                                                                                                                                                                                                      | | ` static void`                                                                                                                          | ` `[startActivityForResult](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#startActivityForResult(android.app.Activity, android.content.Intent, int, android.os.Bundle))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent, int requestCode, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` options) ` Start new activity with options, if able, for which you would like a result when it finished.                                                                                                                                                                                                                        | | ` static void`                                                                                                                          | ` `[startIntentSenderForResult](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#startIntentSenderForResult(android.app.Activity, android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity, `[IntentSender](https://developer.android.com/reference/android/content/IntentSender.html)` intent, int requestCode, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` fillInIntent, int flagsMask, int flagsValues, int extraFlags, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` options) ` Start new IntentSender with options, if able, for which you would like a result when it finished.     | | ` static void`                                                                                                                          | ` `[startPostponedEnterTransition](https://developer.android.com/reference/android/support/v4/app/ActivityCompat#startPostponedEnterTransition(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity.html)` activity) `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#)From class` `[android.support.v4.content.ContextCompat](https://developer.android.com/reference/android/support/v4/content/ContextCompat)` ` |-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` static int`                                                                                               | ` `[checkSelfPermission](https://developer.android.com/reference/android/support/v4/content/ContextCompat#checkSelfPermission(android.content.Context, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String permission) ` Determine whether*you*have been granted a particular permission.                                                                                                                                                                               | | ` static `[Context](https://developer.android.com/reference/android/content/Context.html)                   | ` `[createDeviceProtectedStorageContext](https://developer.android.com/reference/android/support/v4/content/ContextCompat#createDeviceProtectedStorageContext(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Return a new Context object for the current Context but whose storage APIs are backed by device-protected storage.                                                                                                                                  | | ` static File`                                                                                              | ` `[getCodeCacheDir](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getCodeCacheDir(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns the absolute path to the application specific cache directory on the filesystem designed for storing cached code.                                                                                                                                                                   | | ` static int`                                                                                               | ` `[getColor](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getColor(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int id) ` Returns a color associated with a particular resource ID Starting in[M](https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#M), the returned color will be styled for the specified Context's theme.                                                                 | | ` static `[ColorStateList](https://developer.android.com/reference/android/content/res/ColorStateList.html) | ` `[getColorStateList](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getColorStateList(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int id) ` Returns a color state list associated with a particular resource ID.                                                                                                                                                                                                       | | ` static File`                                                                                              | ` `[getDataDir](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getDataDir(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns the absolute path to the directory on the filesystem where all private files belonging to this app are stored.                                                                                                                                                                                | | ` static `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)       | ` `[getDrawable](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getDrawable(android.content.Context, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, int id) ` Returns a drawable object associated with a particular resource ID.                                                                                                                                                                                                                    | | ` static File[]`                                                                                            | ` `[getExternalCacheDirs](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getExternalCacheDirs(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns absolute paths to application-specific directories on all external storage devices where the application can place cache files it owns.                                                                                                                                   | | ` static File[]`                                                                                            | ` `[getExternalFilesDirs](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getExternalFilesDirs(android.content.Context, java.lang.String))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, String type) ` Returns absolute paths to application-specific directories on all external storage devices where the application can place persistent files it owns.                                                                                               | | ` static File`                                                                                              | ` `[getNoBackupFilesDir](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getNoBackupFilesDir(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns the absolute path to the directory on the filesystem similar to[getFilesDir()](https://developer.android.com/reference/android/content/Context.html#getFilesDir()).                                                                                                         | | ` static File[]`                                                                                            | ` `[getObbDirs](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getObbDirs(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns absolute paths to application-specific directories on all external storage devices where the application's OBB files (if there are any) can be found.                                                                                                                                         | | ` static <T> T`                                                                                             | ` `[getSystemService](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getSystemService(android.content.Context, java.lang.Class<T>))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, Class<T> serviceClass) ` Return the handle to a system-level service by class.                                                                                                                                                                                          | | ` static String`                                                                                            | ` `[getSystemServiceName](https://developer.android.com/reference/android/support/v4/content/ContextCompat#getSystemServiceName(android.content.Context, java.lang.Class<?>))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, Class<?> serviceClass) ` Gets the name of the system-level service that is represented by the specified class.                                                                                                                                                  | | ` static boolean`                                                                                           | ` `[isDeviceProtectedStorage](https://developer.android.com/reference/android/support/v4/content/ContextCompat#isDeviceProtectedStorage(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Indicates if the storage APIs of this Context are backed by device-encrypted storage.                                                                                                                                                                                     | | ` static boolean`                                                                                           | ` `[startActivities](https://developer.android.com/reference/android/support/v4/content/ContextCompat#startActivities(android.content.Context, android.content.Intent[], android.os.Bundle))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Intent[]](https://developer.android.com/reference/android/content/Intent.html)` intents, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` options) ` Start a set of activities as a synthesized task stack, if able. | | ` static boolean`                                                                                           | ` `[startActivities](https://developer.android.com/reference/android/support/v4/content/ContextCompat#startActivities(android.content.Context, android.content.Intent[]))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Intent[]](https://developer.android.com/reference/android/content/Intent.html)` intents) ` Start a set of activities as a synthesized task stack, if able.                                                                                                        | | ` static void`                                                                                              | ` `[startActivity](https://developer.android.com/reference/android/support/v4/content/ContextCompat#startActivity(android.content.Context, android.content.Intent, android.os.Bundle))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` options) ` Start an activity with additional launch information, if able.           | | ` static void`                                                                                              | ` `[startForegroundService](https://developer.android.com/reference/android/support/v4/content/ContextCompat#startForegroundService(android.content.Context, android.content.Intent))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` startForegroundService() was introduced in O, just call startService for before O.                                                                            | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v13/app/ActivityCompat#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Protected constructors

### ActivityCompat

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ActivityCompat ()
```

<br />

**This constructor was deprecated in API level 27.1.0.**   
Use[android.support.v4.app.ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat).

This class should not be instantiated, but the constructor must be visible for the class to be extended.

<br />

-

  ## Interfaces

  - [FragmentCompat.OnRequestPermissionsResultCallback](https://developer.android.com/reference/android/support/v13/app/FragmentCompat.OnRequestPermissionsResultCallback)
  - [FragmentCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v13/app/FragmentCompat.PermissionCompatDelegate)
-

  ## Classes

  - [ActivityCompat](https://developer.android.com/reference/android/support/v13/app/ActivityCompat)
  - [FragmentCompat](https://developer.android.com/reference/android/support/v13/app/FragmentCompat)
  - [FragmentPagerAdapter](https://developer.android.com/reference/android/support/v13/app/FragmentPagerAdapter)
  - [FragmentStatePagerAdapter](https://developer.android.com/reference/android/support/v13/app/FragmentStatePagerAdapter)
  - [FragmentTabHost](https://developer.android.com/reference/android/support/v13/app/FragmentTabHost)