Stay organized with collections
Save and categorize content based on your preferences.
added in
version 24.1.0
belongs to Maven artifact com.android.support:support-v13:28.0.0-alpha1
Deprecated since version 27.1.0
ActivityCompat
This package is part of the
Android support library which
is no longer maintained.
The support library has been superseded by AndroidX
which is part of Jetpack .
We recommend using the AndroidX libraries in all new projects. You should also consider
migrating existing projects to AndroidX.
To find the AndroidX class that maps to this deprecated class, see the AndroidX
support library class
mappings .
public
class
ActivityCompat
extends ActivityCompat
This class was deprecated
in API level 27.1.0.
Use android.support.v4.app.ActivityCompat
.
Helper for accessing features in Activity
in a backwards compatible fashion.
Summary
Inherited methods
From
class
android.support.v4.app.ActivityCompat
static
void
finishAffinity (Activity 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 (Activity activity)
Reverses the Activity Scene entry Transition and triggers the calling Activity
to reverse its exit Transition.
static
Uri
getReferrer (Activity activity)
Return information about who launched this activity.
static
boolean
invalidateOptionsMenu (Activity activity)
This method was deprecated
in API level 27.1.0.
Use invalidateOptionsMenu()
directly.
static
void
postponeEnterTransition (Activity activity)
static
DragAndDropPermissionsCompat
requestDragAndDropPermissions (Activity activity, DragEvent dragEvent)
Create DragAndDropPermissionsCompat
object bound to this activity and controlling
the access permissions for content URIs associated with the DragEvent
.
static
void
requestPermissions (Activity activity, String[] permissions, int requestCode)
Requests permissions to be granted to this application.
static
<T extends View >
T
requireViewById (Activity activity, int id)
Finds a view that was identified by the android:id
XML attribute that was processed
in onCreate(Bundle)
, or throws an IllegalArgumentException if the ID is invalid, or
there is no matching view in the hierarchy.
static
void
setEnterSharedElementCallback (Activity activity, SharedElementCallback callback)
When makeSceneTransitionAnimation(Activity, android.view.View, String)
was used to start an Activity, callback
will be called to handle shared elements on the launched Activity.
static
void
setExitSharedElementCallback (Activity activity, SharedElementCallback callback)
When makeSceneTransitionAnimation(Activity, android.view.View, String)
was used to start an Activity, callback
will be called to handle shared elements on the launching Activity.
static
void
setPermissionCompatDelegate (ActivityCompat.PermissionCompatDelegate delegate)
Sets the permission delegate for ActivityCompat
.
static
boolean
shouldShowRequestPermissionRationale (Activity activity, String permission)
Gets whether you should show UI with rationale for requesting a permission.
static
void
startActivityForResult (Activity activity, Intent intent, int requestCode, Bundle options)
Start new activity with options, if able, for which you would like a
result when it finished.
static
void
startIntentSenderForResult (Activity activity, IntentSender intent, int requestCode, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)
Start new IntentSender with options, if able, for which you would like a
result when it finished.
static
void
startPostponedEnterTransition (Activity activity)
From
class
android.support.v4.content.ContextCompat
static
int
checkSelfPermission (Context context, String permission)
Determine whether you have been granted a particular permission.
static
Context
createDeviceProtectedStorageContext (Context context)
Return a new Context object for the current Context but whose storage
APIs are backed by device-protected storage.
static
File
getCodeCacheDir (Context context)
Returns the absolute path to the application specific cache directory on
the filesystem designed for storing cached code.
static
int
getColor (Context context, int id)
Returns a color associated with a particular resource ID
Starting in M
, the returned
color will be styled for the specified Context's theme.
static
ColorStateList
getColorStateList (Context context, int id)
Returns a color state list associated with a particular resource ID.
static
File
getDataDir (Context context)
Returns the absolute path to the directory on the filesystem where all
private files belonging to this app are stored.
static
Drawable
getDrawable (Context context, int id)
Returns a drawable object associated with a particular resource ID.
static
File[]
getExternalCacheDirs (Context 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 (Context 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 (Context context)
Returns the absolute path to the directory on the filesystem similar to
getFilesDir()
.
static
File[]
getObbDirs (Context 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 (Context context, Class<T> serviceClass)
Return the handle to a system-level service by class.
static
String
getSystemServiceName (Context context, Class<?> serviceClass)
Gets the name of the system-level service that is represented by the specified class.
static
boolean
isDeviceProtectedStorage (Context context)
Indicates if the storage APIs of this Context are backed by
device-encrypted storage.
static
boolean
startActivities (Context context, Intent[] intents, Bundle options)
Start a set of activities as a synthesized task stack, if able.
static
boolean
startActivities (Context context, Intent[] intents)
Start a set of activities as a synthesized task stack, if able.
static
void
startActivity (Context context, Intent intent, Bundle options)
Start an activity with additional launch information, if able.
static
void
startForegroundService (Context context, Intent intent)
startForegroundService() was introduced in O, just call startService
for before O.
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
ActivityCompat ()
This constructor was deprecated
in API level 27.1.0.
Use android.support.v4.app.ActivityCompat
.
This class should not be instantiated, but the constructor must be
visible for the class to be extended.
Content and code samples on this page are subject to the licenses described in the Content License . Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-11 UTC."],[],[]]