Context - API Reference - Android Developers
Context - API Reference - Android Developers
[Link] (/reference/java/lang/Object)
↳ [Link]
AbstractInputMethodService AbstractInputMethodS
(/reference/android/inputmethodservice/AbstractInputMethodService)
[Link] 1/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 2/302
2/15/26, 8:49 PM Context | API reference | Android Developers
InputMethodService InputMethodService p
(/reference/android/inputmethodservice/InputMethodService) customize.
[Link] 3/302
2/15/26, 8:49 PM Context | API reference | Android Developers
OffHostApduService OffHostApduService is
(/reference/android/nfc/cardemulation/OffHostApduService) NFC applications that
QuickAccessWalletService A QuickAccessWall
(/reference/android/service/quickaccesswallet/QuickAccessWalletService)
SpellCheckerService SpellCheckerService p
(/reference/android/service/textservice/SpellCheckerService)
[Link] 4/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Summary
Nested classes
class [Link]
(/reference/android/content/[Link])
Constants
[Link] 5/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 6/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 7/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 8/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 9/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 10/302
2/15/26, 8:49 PM Context | API reference | Android Developers
The default device ID, which is the ID of the primary (non-virtual) devi
[Link] 11/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 12/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 13/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Database open flag: when set, the database is opened with write-ahe
[Link] 14/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Database open flag: when set, the database is opened without suppo
File creation mode: the default mode, where the created file can only
[Link] 15/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 16/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 17/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 18/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 19/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 20/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Public constructors
Context (/reference/android/content/Context#Context())()
Public methods
See bindIsolatedService([Link]
(/reference/android/content/Context#bindIsolate
(/reference/android/content/[Link]
See bindService([Link]
[Link](long) (/reference/and
See bindService([Link]
(/reference/android/content/Context#bindService
[Link] 21/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/[Link]
See bindServiceAsUser([Link].
(/reference/android/content/Context#bindService
(/reference/android/content/[Link]
[Link] 22/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 23/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 24/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 25/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 26/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 27/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 28/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 29/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 30/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 31/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link] 32/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Version of sendBroadcast([Link]
Version of sendBroadcast([Link]
void sendBroadcastWithMultiplePermissions (
(/reference/java/lang/String) receiverPermiss
void sendOrderedBroadcast
(/reference/android/content/Context#sendOrdere
(/reference/android/content/Intent) intent, St
resultReceiver, Handler (/reference/androi
Version of sendOrderedBroadcast(android.
(/reference/android/content/Context#sendOrdere
Op to enforce restrictions on which receivers the
[Link] 33/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Version of sendBroadcast([Link]
void sendOrderedBroadcast
(/reference/android/content/Context#sendOrdere
(/reference/android/content/Intent) intent, St
Handler (/reference/android/os/Handler) sched
Version of sendBroadcast([Link]
Version of sendOrderedBroadcast(android.
(/reference/android/content/Context#sendOrdere
the broadcast will be sent to.
[Link] 34/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/java/lang/String) initialData, Bu
Same as startActivities([Link]
Same as startActivity([Link].
[Link] 35/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Same as startIntentSender([Link]
(/reference/android/content/Context#startIntentS
Like startActivity([Link]
[Link] 36/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Inherited methods
boolean equals
(/reference/java/lang/Object#equals([Link])
(Object (/reference/java/lang/Object) obj)
[Link] 37/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Constants
ACCESSIBILITY_SERVICE
Added in API level 4 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 38/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AccessibilityManager (/reference/android/view/accessibility/AccessibilityManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AccountManager (/reference/android/accounts/AccountManager)
[Link] 39/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ActivityManager (/reference/android/app/ActivityManager)
ADVANCED_PROTECTION_SERVICE
Added in API level 36 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AdvancedProtectionManager
(/reference/android/security/advancedprotection/AdvancedProtectionManager)
[Link] 40/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AlarmManager (/reference/android/app/AlarmManager)
APPWIDGET_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
APP_FUNCTION_SERVICE
Added in API level 36 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 41/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AppOpsManager (/reference/android/app/AppOpsManager)
APP_SEARCH_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 42/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
AudioManager (/reference/android/media/AudioManager)
[Link] 43/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
BIND_ABOVE_CLIENT
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIND_ADJUST_WITH_ACTIVITY
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 44/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_ALLOW_ACTIVITY_STARTS
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIND_ALLOW_OOM_MANAGEMENT
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 45/302
2/15/26, 8:49 PM Context | API reference | Android Developers
: allow the process hosting the bound service to go through its normal memory
management. It will be treated more like a running service, allowing the system to
(temporarily) expunge the process if low on memory or for some other whim it may have,
and being more aggressive about making it a candidate to be killed (and restarted) if
running for a long time.
[Link] 46/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_DEBUG_UNBIND
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIND_EXTERNAL_SERVICE
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
When using this flag, the code for the service being bound will execute under the calling
application's package name and user ID. Because the service must be an isolated
process, it will not have direct access to the application's data, though. The purpose of
[Link] 47/302
2/15/26, 8:49 PM Context | API reference | Android Developers
this flag is to allow applications to provide services that are attributed to the app using
the service, rather than the application providing the service.
BIND_EXTERNAL_SERVICE_LONG
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 48/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_INCLUDE_CAPABILITIES
Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIND_NOT_FOREGROUND
Added in API level 8 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 49/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_NOT_PERCEPTIBLE
Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIND_PACKAGE_ISOLATED_PROCESS
Added in API level 35 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Specifying this flag allows multiple isolated services defined in the same package to be
running in a single shared isolated process. This shared isolated process must be
specified since this flag will not work with the default application process.
[Link] 50/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_SHARED_ISOLATED_PROCESS
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 51/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_WAIVE_PRIORITY
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
BIOMETRIC_SERVICE
Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(Class)
(/reference/android/content/Context#getSystemService([Link]<T>))
BiometricManager (/reference/android/hardware/biometrics/BiometricManager)
BLOB_STORE_SERVICE
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 52/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
BlobStoreManager (/reference/android/app/blob/BlobStoreManager)
BLUETOOTH_SERVICE
Added in API level 18 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
BUGREPORT_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 53/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
BugreportManager (/reference/android/os/BugreportManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
CameraManager (/reference/android/hardware/camera2/CameraManager)
CAPTIONING_SERVICE
Added in API level 19 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 54/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
CaptioningManager (/reference/android/view/accessibility/CaptioningManager)
CARRIER_CONFIG_SERVICE
Added in API level 23 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
CarrierConfigManager (/reference/android/telephony/CarrierConfigManager)
[Link] 55/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Note: This service is not available on Wear OS, Android TV, or Android Auto devices. On these form
factors, calls to #getSystemService for this service will return null.
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ChooserManager (/reference/android/service/chooser/ChooserManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ClipboardManager (/reference/android/content/ClipboardManager)
[Link] 56/302
2/15/26, 8:49 PM Context | API reference | Android Developers
COMPANION_DEVICE_SERVICE
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
CompanionDeviceManager (/reference/android/companion/CompanionDeviceManager)
CONNECTIVITY_DIAGNOSTICS_SERVICE
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ConnectivityDiagnosticsManager (/reference/android/net/ConnectivityDiagnosticsManager)
[Link] 57/302
2/15/26, 8:49 PM Context | API reference | Android Developers
CONNECTIVITY_SERVICE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ConnectivityManager (/reference/android/net/ConnectivityManager)
CONSUMER_IR_SERVICE
Added in API level 19 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ConsumerIrManager (/reference/android/hardware/ConsumerIrManager)
[Link] 58/302
2/15/26, 8:49 PM Context | API reference | Android Developers
CONTACT_KEYS_SERVICE
Added in API level 35 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
E2eeContactKeysManager (/reference/android/provider/E2eeContactKeysManager)
CONTEXT_IGNORE_SECURITY
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
CONTEXT_INCLUDE_CODE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 59/302
2/15/26, 8:49 PM Context | API reference | Android Developers
CONTEXT_RESTRICTED
Added in API level 4 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
CREDENTIAL_SERVICE
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 60/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
CredentialManager (/reference/android/credentials/CredentialManager)
CROSS_PROFILE_APPS_SERVICE
Added in API level 28 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
[Link] 61/302
2/15/26, 8:49 PM Context | API reference | Android Developers
The default device ID, which is the ID of the primary (non-virtual) device.
DEVICE_LOCK_SERVICE
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
DEVICE_POLICY_SERVICE
Added in API level 8 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 62/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
DISPLAY_HASH_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
[Link] 63/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
DisplayManager (/reference/android/hardware/display/DisplayManager)
DOMAIN_VERIFICATION_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
DomainVerificationManager
(/reference/android/content/pm/verify/domain/DomainVerificationManager)
DOWNLOAD_SERVICE
Added in API level 9 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 64/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
[Link] 65/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
EuiccManager (/reference/android/telephony/euicc/EuiccManager)
FILE_INTEGRITY_SERVICE
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
FileIntegrityManager (/reference/android/security/FileIntegrityManager)
[Link] 66/302
2/15/26, 8:49 PM Context | API reference | Android Developers
GameManager (/reference/android/app/GameManager) .
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
GRAMMATICAL_INFLECTION_SERVICE
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
HARDWARE_PROPERTIES_SERVICE
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 67/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
HEALTHCONNECT_SERVICE
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
HealthConnectManager (/reference/android/health/connect/HealthConnectManager)
INPUT_METHOD_SERVICE
Added in API level 3 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 68/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
InputManager (/reference/android/hardware/input/InputManager)
See also:
[Link] 69/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
JOB_SCHEDULER_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
JobScheduler (/reference/android/app/job/JobScheduler)
See also:
[Link] 70/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
KeyguardManager (/reference/android/app/KeyguardManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
KeyStoreManager (/reference/android/security/keystore/KeyStoreManager)
LAUNCHER_APPS_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 71/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
LauncherApps (/reference/android/content/pm/LauncherApps)
LAYOUT_INFLATER_SERVICE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
LayoutInflater (/reference/android/view/LayoutInflater)
See also:
[Link] 72/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
LocationManager (/reference/android/location/LocationManager)
MEDIA_COMMUNICATION_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 73/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaCommunicationManager (/reference/android/media/MediaCommunicationManager)
MEDIA_METRICS_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaMetricsManager (/reference/android/media/metrics/MediaMetricsManager)
MEDIA_PROJECTION_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 74/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaProjectionManager (/reference/android/media/projection/MediaProjectionManager)
MEDIA_QUALITY_SERVICE
Added in API level 36 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaQualityManager (/reference/android/media/quality/MediaQualityManager)
MEDIA_ROUTER_SERVICE
Added in API level 16 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
[Link] 75/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaRouter (/reference/android/media/MediaRouter)
MEDIA_SESSION_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
MediaSessionManager (/reference/android/media/session/MediaSessionManager)
See also:
[Link] 76/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
MODE_ENABLE_WRITE_AHEAD_LOGGING
Added in API level 16 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Database open flag: when set, the database is opened with write-ahead logging enabled
by default.
See also:
[Link] 77/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link]()
(/reference/android/database/sqlite/SQLiteDatabase#enableWriteAheadLogging())
MODE_MULTI_PROCESS
Added in API level 11 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 23 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
SharedPreference loading flag: when set, the file on disk will be checked for modification
even if the shared preferences instance is already loaded in this process. This behavior is
sometimes desired in cases where the application has multiple processes, all writing to
the same SharedPreferences file. Generally there are better forms of communication
between processes, though.
This was the legacy (but undocumented) behavior in and before Gingerbread (Android
2.3) and this flag is implied when targeting such releases. For applications targeting SDK
versions greater than Android 2.3, this flag must be explicitly set if desired.
See also:
getSharedPreferences(String, int)
(/reference/android/content/Context#getSharedPreferences([Link],%20int))
[Link] 78/302
2/15/26, 8:49 PM Context | API reference | Android Developers
MODE_NO_LOCALIZED_COLLATORS
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Database open flag: when set, the database is opened without support for localized
collators.
See also:
SQLiteDatabase.NO_LOCALIZED_COLLATORS
(/reference/android/database/sqlite/SQLiteDatabase#NO_LOCALIZED_COLLATORS)
File creation mode: the default mode, where the created file can only be accessed by the
calling application (or all applications sharing the same user ID).
MODE_WORLD_READABLE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 79/302
2/15/26, 8:49 PM Context | API reference | Android Developers
File creation mode: allow all other applications to have read access to the created file.
See also:
FileProvider ([Link]
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PERMISSION)
MODE_WORLD_WRITEABLE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 80/302
2/15/26, 8:49 PM Context | API reference | Android Developers
File creation mode: allow all other applications to have write access to the created file.
See also:
FileProvider ([Link]
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PERMISSION)
NETWORK_STATS_SERVICE
Added in API level 23 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
NetworkStatsManager (/reference/android/app/usage/NetworkStatsManager)
[Link] 81/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
NOTIFICATION_SERVICE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
NotificationManager (/reference/android/app/NotificationManager)
[Link] 82/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
NsdManager (/reference/android/net/nsd/NsdManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
OverlayManager (/reference/android/content/om/OverlayManager)
[Link] 83/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
PERFORMANCE_HINT_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
PERSISTENT_DATA_BLOCK_SERVICE
Added in API level 35 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 84/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
PersistentDataBlockManager
(/reference/android/service/persistentdata/PersistentDataBlockManager)
[Link] 85/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
PrintManager (/reference/android/print/PrintManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
RECEIVER_EXPORTED
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 86/302
2/15/26, 8:49 PM Context | API reference | Android Developers
RECEIVER_NOT_EXPORTED
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
RECEIVER_VISIBLE_TO_INSTANT_APPS
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
RESTRICTIONS_SERVICE
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 87/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
RestrictionsManager (/reference/android/content/RestrictionsManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
RoleManager (/reference/android/app/role/RoleManager)
[Link] 88/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
SatelliteManager (/reference/android/telephony/satellite/SatelliteManager)
Configuration.UI_MODE_TYPE_WATCH
(/reference/android/content/res/Configuration#UI_MODE_TYPE_WATCH) does not support
SearchManager (/reference/android/app/SearchManager) .
See also:
getSystemService(Class)
(/reference/android/content/Context#getSystemService([Link]<T>))
SearchManager (/reference/android/app/SearchManager)
[Link] 89/302
2/15/26, 8:49 PM Context | API reference | Android Developers
SECURITY_STATE_SERVICE
Added in API level 35 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
SecurityStateManager (/reference/android/os/SecurityStateManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
SensorManager (/reference/android/hardware/SensorManager)
[Link] 90/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
ShortcutManager (/reference/android/content/pm/ShortcutManager)
STATUS_BAR_SERVICE
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
StatusBarManager (/reference/android/app/StatusBarManager)
[Link] 91/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
StorageManager (/reference/android/os/storage/StorageManager)
STORAGE_STATS_SERVICE
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
StorageStatsManager (/reference/android/app/usage/StorageStatsManager)
[Link] 92/302
2/15/26, 8:49 PM Context | API reference | Android Developers
SYSTEM_HEALTH_SERVICE
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TelecomManager (/reference/android/telecom/TelecomManager)
[Link] 93/302
2/15/26, 8:49 PM Context | API reference | Android Developers
TELEPHONY_IMS_SERVICE
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
TELEPHONY_PHONE_NUMBER_SERVICE
Added in version 36.1 (/topic/libraries/support-library/revisions)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
PhoneNumberManager (/reference/android/telephony/PhoneNumberManager)
[Link] 94/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TelephonyManager (/reference/android/telephony/TelephonyManager)
TELEPHONY_SUBSCRIPTION_SERVICE
Added in API level 22 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
SubscriptionManager (/reference/android/telephony/SubscriptionManager)
TETHERING_SERVICE
Added in API level 36 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 95/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
TetheringManager (/reference/android/net/TetheringManager)
TEXT_CLASSIFICATION_SERVICE
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TextClassificationManager (/reference/android/view/textclassifier/TextClassificationManager)
TEXT_SERVICES_MANAGER_SERVICE
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 96/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TvAdManager (/reference/android/media/tv/ad/TvAdManager)
[Link] 97/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TvInputManager (/reference/android/media/tv/TvInputManager)
TV_INTERACTIVE_APP_SERVICE
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
TvInteractiveAppManager (/reference/android/media/tv/interactive/TvInteractiveAppManager)
[Link] 98/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
USAGE_STATS_SERVICE
Added in API level 22 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
UsageStatsManager (/reference/android/app/usage/UsageStatsManager)
[Link] 99/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
UsbManager (/reference/android/hardware/usb/UsbManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
UserManager (/reference/android/os/UserManager)
VIBRATOR_MANAGER_SERVICE
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 100/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
VibratorManager (/reference/android/os/VibratorManager)
VIBRATOR_SERVICE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
Vibrator (/reference/android/os/Vibrator)
VIRTUAL_DEVICE_SERVICE
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 101/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
VirtualDeviceManager (/reference/android/companion/virtual/VirtualDeviceManager)
VPN_MANAGEMENT_SERVICE
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
[Link] 102/302
2/15/26, 8:49 PM Context | API reference | Android Developers
WALLPAPER_SERVICE
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WIFI_AWARE_SERVICE
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WifiAwareManager (/reference/android/net/wifi/aware/WifiAwareManager)
[Link] 103/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WifiP2pManager (/reference/android/net/wifi/p2p/WifiP2pManager)
WIFI_RTT_RANGING_SERVICE
Added in API level 28 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WifiRttManager (/reference/android/net/wifi/rtt/WifiRttManager)
[Link] 104/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WifiManager (/reference/android/net/wifi/WifiManager)
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
WindowManager (/reference/android/view/WindowManager)
Public constructors
[Link] 105/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Context
public Context ()
Public methods
Parameters
[Link] 106/302
2/15/26, 8:49 PM Context | API reference | Android Developers
service Intent : Identifies the service to connect to. The Intent must specify
This value cannot be null .
instanceName String : Unique identifier for the service instance. Each unique name
and periods.
This value cannot be null .
Returns
Throws
[Link] 107/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
[Link] (/reference/android/[Link]#isolatedProcess)
Parameters
[Link] 108/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
boolean
This method only accepts a 32 bits flag, to pass in a 64 bits flag, call
bindService([Link],
[Link] 109/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link], [Link],
[Link])
(/reference/android/content/Context#bindService([Link],%[Link].
BindServiceFlags,%[Link],%[Link]))
instead.
Parameters
BIND_DEBUG_UNBIND
(/reference/android/content/Context#BIND_DEBUG_UNBIND)
BIND_NOT_FOREGROUND
(/reference/android/content/Context#BIND_NOT_FOREGROUND)
BIND_ABOVE_CLIENT
(/reference/android/content/Context#BIND_ABOVE_CLIENT)
BIND_ALLOW_OOM_MANAGEMENT
(/reference/android/content/Context#BIND_ALLOW_OOM_MANAG
BIND_WAIVE_PRIORITY
(/reference/android/content/Context#BIND_WAIVE_PRIORITY)
BIND_IMPORTANT (/reference/android/content/Context#BIND_IMP
BIND_ADJUST_WITH_ACTIVITY
(/reference/android/content/Context#BIND_ADJUST_WITH_ACTIVI
BIND_NOT_PERCEPTIBLE
(/reference/android/content/Context#BIND_NOT_PERCEPTIBLE)
BIND_ALLOW_ACTIVITY_STARTS
(/reference/android/content/Context#BIND_ALLOW_ACTIVITY_STA
BIND_INCLUDE_CAPABILITIES
(/reference/android/content/Context#BIND_INCLUDE_CAPABILITIE
BIND_SHARED_ISOLATED_PROCESS
(/reference/android/content/Context#BIND_SHARED_ISOLATED_P
BIND_PACKAGE_ISOLATED_PROCESS
(/reference/android/content/Context#BIND_PACKAGE_ISOLATED_
[Link] 110/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_EXTERNAL_SERVICE
(/reference/android/content/Context#BIND_EXTERNAL_SERVICE)
Returns
[Link] 111/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
boolean
If the service does not support binding, it may return null from its onBind()
(/reference/android/app/Service#onBind([Link])) method. If it does, then the
[Link] 112/302
2/15/26, 8:49 PM Context | API reference | Android Developers
ServiceConnection's onNullBinding()
(/reference/android/content/ServiceConnection#onNullBinding([Link]))
method will be invoked instead of onServiceConnected()
(/reference/android/content/ServiceConnection#onServiceConnected([Link]
me,%[Link]))
.
This method only accepts a int type flag, to pass in a long type flag, call
bindService([Link], [Link],
[Link])
(/reference/android/content/Context#bindService([Link],%[Link]
Connection,%[Link]))
instead.
Parameters
service Intent : Identifies the service to connect to. The Intent must specify
explicit component name.
This value cannot be null .
[Link] 113/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BIND_AUTO_CREATE
(/reference/android/content/Context#BIND_AUTO_CREATE)
BIND_DEBUG_UNBIND
(/reference/android/content/Context#BIND_DEBUG_UNBIND)
BIND_NOT_FOREGROUND
(/reference/android/content/Context#BIND_NOT_FOREGROUND)
BIND_ABOVE_CLIENT
(/reference/android/content/Context#BIND_ABOVE_CLIENT)
BIND_ALLOW_OOM_MANAGEMENT
(/reference/android/content/Context#BIND_ALLOW_OOM_MANAG
BIND_WAIVE_PRIORITY
(/reference/android/content/Context#BIND_WAIVE_PRIORITY)
BIND_IMPORTANT
(/reference/android/content/Context#BIND_IMPORTANT)
BIND_ADJUST_WITH_ACTIVITY
(/reference/android/content/Context#BIND_ADJUST_WITH_ACTIVI
BIND_NOT_PERCEPTIBLE
(/reference/android/content/Context#BIND_NOT_PERCEPTIBLE)
BIND_INCLUDE_CAPABILITIES
(/reference/android/content/Context#BIND_INCLUDE_CAPABILITIE
Returns
boolean true if the system is in the process of bringing up a service that your
permission to bind to; false if the system couldn't find the service o
doesn't have permission to bind to it. Regardless of the return value, y
unbindService(ServiceConnection)
(/reference/android/content/Context#unbindService([Link]
to release the connection.
[Link] 114/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
SecurityException If the caller does not have permission to access the service or
(/reference/java/lang/SecurityException) found. Call unbindService(ServiceConnection)
(/reference/android/content/Context#unbindService(android.c
to release the connection when this exception is thrown.
See also:
unbindService(ServiceConnection)
(/reference/android/content/Context#unbindService([Link]))
startService(Intent) (/reference/android/content/Context#startService([Link]))
Parameters
[Link] 115/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
boolean
[Link] 116/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
service Intent : Identifies the service to connect to. The Intent must specify
explicit component name.
This value cannot be null .
[Link] 117/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
boolean true if the system is in the process of bringing up a service that your
permission to bind to; false if the system couldn't find the service. Y
unbindService(ServiceConnection)
(/reference/android/content/Context#unbindService([Link]
to release the connection even if this method returned false .
Throws
SecurityException if the client does not have the required permission to bind.
(/reference/java/lang/SecurityException)
See bindServiceAsUser([Link],
[Link], int, [Link])
(/reference/android/content/Context#bindServiceAsUser([Link],%[Link].
ServiceConnection,%20int,%[Link]))
Call [Link](long)
(/reference/android/content/[Link]#of(long)) to obtain a BindServiceFlags
object.
[Link] 118/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
boolean
checkCallingOrSelfPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether the calling process of an IPC or you have been granted a particular
permission. This is the same as checkCallingPermission(String)
(/reference/android/content/Context#checkCallingPermission([Link])) , except it grants
your own permissions if you are not currently processing an IPC. Use with care!
Parameters
[Link] 119/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the calling pid/uid is allowed that permission, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link](String, String)
(/reference/android/content/pm/PackageManager#checkPermission([Link],%[Link]
ng))
checkCallingPermission(String)
(/reference/android/content/Context#checkCallingPermission([Link]))
checkCallingOrSelfUriPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether the calling process of an IPC or you has been granted permission to
access a specific URI. This is the same as checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int)) , except it
grants your own permissions if you are not currently processing an IPC. Use with care!
[Link] 120/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the caller is allowed to access that uri, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int))
checkCallingOrSelfUriPermissions
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 121/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Determine whether the calling process of an IPC or you has been granted permission to
access a list of URIs. This is the same as checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int)) , except it
grants your own permissions if you are not currently processing an IPC. Use with care!
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
[Link] 122/302
2/15/26, 8:49 PM Context | API reference | Android Developers
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int))
checkCallingPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether the calling process of an IPC you are handling has been granted a
particular permission. This is basically the same as calling
checkPermission([Link], int, int)
(/reference/android/content/Context#checkPermission([Link],%20int,%20int)) with the pid
and uid returned by [Link]() (/reference/android/os/Binder#getCallingPid())
and [Link]() (/reference/android/os/Binder#getCallingUid()) . One important
difference is that if you are not currently processing an IPC, this function will always fail.
This is done to protect against accidentally leaking permissions; you can use
checkCallingOrSelfPermission(String)
(/reference/android/content/Context#checkCallingOrSelfPermission([Link])) to avoid this
protection.
Parameters
Returns
[Link] 123/302
2/15/26, 8:49 PM Context | API reference | Android Developers
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the calling pid/uid is allowed that permission, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link](String, String)
(/reference/android/content/pm/PackageManager#checkPermission([Link],%[Link]
ng))
checkCallingOrSelfPermission(String)
(/reference/android/content/Context#checkCallingOrSelfPermission([Link]))
checkCallingUriPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether the calling process and uid has been granted permission to access a
specific URI. This is basically the same as calling
checkUriPermission([Link], int, int, int)
(/reference/android/content/Context#checkUriPermission([Link],%20int,%20int,%20int))
with the pid and uid returned by [Link]()
(/reference/android/os/Binder#getCallingPid()) and [Link]()
[Link] 124/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the caller is allowed to access that uri, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link] 125/302
2/15/26, 8:49 PM Context | API reference | Android Developers
checkCallingUriPermissions
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether the calling process and uid has been granted permission to access a
list of URIs. This is basically the same as calling checkUriPermissions([Link],
int, int, int)
(/reference/android/content/Context#checkUriPermissions([Link]<[Link]>,%20int,%20i
nt,%20int))
with the pid and uid returned by [Link]()
(/reference/android/os/Binder#getCallingPid()) and [Link]()
(/reference/android/os/Binder#getCallingUid()) . One important difference is that if you are not
currently processing an IPC, this function will always fail.
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
[Link] 126/302
2/15/26, 8:49 PM Context | API reference | Android Developers
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
This value cannot be null .
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
checkContentUriPermissionFull
Added in API level 35 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Determine whether a particular process and uid has been granted permission to access a
specific content URI.
Parameters
[Link] 127/302
2/15/26, 8:49 PM Context | API reference | Android Developers
pid int : (Optional) The process ID being checked against. If the pid is un
pass -1.
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the given pid/uid is allowed to access that uri, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link] 128/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Determine whether the given permission is allowed for a particular process and user ID
running in the system.
Parameters
uid int : The UID being checked against. A uid of 0 is the root user,
which will pass every permission check.
Returns
[Link] 129/302
2/15/26, 8:49 PM Context | API reference | Android Developers
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the given pid/uid is allowed that permission, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link](String, String)
(/reference/android/content/pm/PackageManager#checkPermission([Link],%[Link]
ng))
checkCallingPermission(String)
(/reference/android/content/Context#checkCallingPermission([Link]))
Parameters
[Link] 130/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
you have the permission, or PackageManager.PERMISSION_DENIE
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
[Link](String, String)
(/reference/android/content/pm/PackageManager#checkPermission([Link],%[Link]
ng))
checkCallingPermission(String)
(/reference/android/content/Context#checkCallingPermission([Link]))
Check both a Uri and normal permission. This allows you to perform both
checkPermission(String, int, int)
(/reference/android/content/Context#checkPermission([Link],%20int,%20int)) and
checkUriPermission(Uri, int, int, int)
[Link] 131/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/Context#checkUriPermission([Link],%20int,%20int,%20int)) in
one call.
Parameters
uri Uri : The Uri whose permission is to be checked, or null to not do this
readPermission String : The permission that provides overall read access, or null to n
this check.
writePermission String : The permission that provides overall write access, or null to
this check.
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the caller is allowed to access that uri or holds one of the given permi
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
[Link] 132/302
2/15/26, 8:49 PM Context | API reference | Android Developers
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
Determine whether a particular process and uid has been granted permission to access a
specific URI. This only checks for permissions that have been explicitly granted -- if the
given process/uid has more general access to the URI's content provider then this check
will always fail.
Parameters
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
[Link] 133/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
int PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_GRA
the given pid/uid is allowed to access that uri, or
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DEN
is not.
Value is one of the following:
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int))
Determine whether a particular process and uid has been granted permission to access a
list of URIs. This only checks for permissions that have been explicitly granted -- if the
[Link] 134/302
2/15/26, 8:49 PM Context | API reference | Android Developers
given process/uid has more general access to the URI's content provider then this check
will always fail. Note: On SDK Version Build.VERSION_CODES.S
(/reference/android/os/Build.VERSION_CODES#S) , calling this method from a secondary-user's
context will incorrectly return PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_DENIED) for all {code uris}.
Parameters
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
modeFlags int : The access modes to check for the list of uris.
Value is either 0 or a combination of the following:
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Returns
[Link] 135/302
2/15/26, 8:49 PM Context | API reference | Android Developers
PackageManager.PERMISSION_GRANTED
(/reference/android/content/pm/PackageManager#PERMISSION_G
PackageManager.PERMISSION_DENIED
(/reference/android/content/pm/PackageManager#PERMISSION_D
See also:
checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int))
Throws
IOException
(/reference/java/io/IOException)
createAttributionContext
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 136/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Return a new Context object for the current Context but attribute to a different tag. In
complex apps attribution tagging can be used to distinguish between separate logical
parts.
Parameters
attributionTag String : The tag or null to create a context for the default.
Returns
See also:
getAttributionTag() (/reference/android/content/Context#getAttributionTag())
createConfigurationContext
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return a new Context object for the current Context but whose resources are adjusted to
match the given Configuration. Each call to this method returns a new instance of a
Context object; Context objects are not shared, however common state (ClassLoader,
[Link] 137/302
2/15/26, 8:49 PM Context | API reference | Android Developers
other Resources for the same configuration) may be so the Context itself can be fairly
lightweight.
Parameters
Returns
Parameters
[Link] 138/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
See also:
ContextParams (/reference/android/content/ContextParams)
createContextForSplit
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return a new Context object for the given split name. The new Context has a ClassLoader
and Resources object that can access the split's and all of its dependencies'
code/resources. Each call to this method returns a new instance of a Context object;
Context objects are not shared, however common state (ClassLoader, other Resources for
the same split) may be so the Context itself can be fairly lightweight.
Parameters
splitName String : The name of the split to include, as declared in the split's
[Link] .
Returns
[Link] 139/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
[Link]
(/reference/android/content/pm/[Link])
createDeviceContext
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Returns a new Context object from the current context but with device association given
by the deviceId . Each call to this method returns a new instance of a context object.
Context objects are not shared; however, common state (such as the ClassLoader
(/reference/java/lang/ClassLoader) and other resources for the same configuration) can be
shared, so the Context itself is lightweight.
Applications that run on virtual devices may use this method to access the default device
capabilities and functionality (by passing Context.DEVICE_ID_DEFAULT
(/reference/android/content/Context#DEVICE_ID_DEFAULT) . Similarly, applications running on
the default device may access the functionality of virtual devices.
Note that the newly created instance will be associated with the same display as the
parent Context, regardless of the device ID passed here.
Parameters
Returns
[Link] 140/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
See also:
getDeviceId() (/reference/android/content/Context#getDeviceId())
[Link]()
(/reference/android/companion/virtual/VirtualDeviceManager#getVirtualDevices())
createDeviceProtectedStorageContext
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return a new Context object for the current Context but whose storage APIs are backed
by device-protected storage.
On devices with direct boot, data stored in this location is encrypted with a key tied to the
physical device, and it can be accessed immediately after the device has booted
successfully, both before and after the user has authenticated with their credentials (such
as a lock pattern or PIN).
If the underlying device does not have the ability to store device-protected and
credential-protected data using different keys, then both storage areas will become
[Link] 141/302
2/15/26, 8:49 PM Context | API reference | Android Developers
available at the same time. They remain as two distinct storage locations on disk, and only
the window of availability changes.
Each call to this method returns a new instance of a Context object; Context objects are
not shared, however common state (ClassLoader, other Resources for the same
configuration) may be so the Context itself can be fairly lightweight.
Returns
Context
(/reference/android/content/Context)
See also:
isDeviceProtectedStorage() (/reference/android/content/Context#isDeviceProtectedStorage())
createDisplayContext
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Returns a new Context object from the current context but with resources adjusted to
match the metrics of display . Each call to this method returns a new instance of a
context object. Context objects are not shared; however, common state (such as the
ClassLoader (/reference/java/lang/ClassLoader) and other resources for the same
configuration) can be shared, so the Context itself is lightweight.
Note: This Context is not expected to be updated with new configuration if the
underlying display configuration changes and the cached Resources it returns could be
stale. It is suggested to use [Link]
(/reference/android/hardware/display/[Link]) to listen for changes and
re-create an instance if necessary.
[Link] 142/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
display Display : The display to which the current context's resources are
adjusted.
This value cannot be null .
Returns
createPackageContext
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return a new Context object for the given application name. This Context is the same as
what the named application gets when it is launched, containing the same resources and
class loader. Each call to this method returns a new instance of a Context object; Context
objects are not shared, however they share common state (Resources, ClassLoader, etc)
so the Context instance itself is fairly lightweight.
[Link] 143/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws [Link]
(/reference/android/content/pm/[Link]) if there is no
application with the given package name.
Parameters
CONTEXT_INCLUDE_CODE
(/reference/android/content/Context#CONTEXT_INCLUDE_CODE)
CONTEXT_IGNORE_SECURITY
(/reference/android/content/Context#CONTEXT_IGNORE_SECURIT
CONTEXT_RESTRICTED
(/reference/android/content/Context#CONTEXT_RESTRICTED)
Returns
Throws
[Link] 144/302
2/15/26, 8:49 PM Context | API reference | Android Developers
SecurityException (/reference/java/lang/SecurityException)
createWindowContext
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
A window context is a context that can be used to add non-activity windows, such as
[Link].TYPE_APPLICATION_OVERLAY
(/reference/android/view/[Link]#TYPE_APPLICATION_OVERLAY) . A window
context must be created from a context that has an associated Display
Activity (/reference/android/app/Activity) or a
(/reference/android/view/Display) , such as
context created with createDisplayContext([Link])
(/reference/android/content/Context#createDisplayContext([Link])) .
...
final DisplayManager dm = [Link]([Link]);
final Display primaryDisplay = [Link](DEFAULT_DISPLAY);
final Context windowContext = [Link](primaryDisplay
.createWindowContext(TYPE_APPLICATION_OVERLAY, null);
final View overlayView = [Link](windowContext).inflate(someLayoutXml,
// [Link] initialization
...
// The types used in addView and createWindowContext must match.
[Link] = TYPE_APPLICATION_OVERLAY;
...
[Link] 145/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link]([Link]).addView(overlayView, mPa
This context's configuration and resources are adjusted to an area of the display where
the windows with provided type will be added. Note that all windows associated with
the same context will have an affinity and can only be moved together between
different displays or areas on a display. If there is a need to add different window
types, or non-associated windows, separate Contexts should be used.
Creating a window context is an expensive operation. Misuse of this API may lead to a
huge performance drop. The best practice is to use the same window context when
possible. An approach is to create one window context with specific window type and
display and use it everywhere it's needed.
[Link] 146/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
[Link].TYPE_BASE_APPLICATION
(/reference/android/view/[Link]#TYPE_B
[Link] 147/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link].TYPE_APPLICATION
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_STARTI
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_DRAWN_APPLICATION
(/reference/android/view/[Link]#TYPE_D
[Link].TYPE_APPLICATION_PANEL
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_MEDIA
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_SUB_PA
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_ATTACH
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_STATUS_BAR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_SEARCH_BAR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_PHONE
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_SYSTEM_ALERT
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_TOAST
(/reference/android/view/[Link]#TYPE_T
[Link].TYPE_SYSTEM_OVERLAY
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_PRIORITY_PHONE
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_SYSTEM_DIALOG
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_KEYGUARD_DIALOG
(/reference/android/view/[Link]#TYPE_K
[Link].TYPE_SYSTEM_ERROR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_INPUT_METHOD
(/reference/android/view/[Link]#TYPE_IN
[Link].TYPE_INPUT_METHOD_DIALO
(/reference/android/view/[Link]#TYPE_IN
[Link] 148/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link].TYPE_WALLPAPER
(/reference/android/view/[Link]#TYPE_W
[Link].TYPE_PRIVATE_PRESENTATI
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_ACCESSIBILITY_OVER
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_OVERLA
(/reference/android/view/[Link]#TYPE_A
Returns
Throws
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
getSystemService(Class)
(/reference/android/content/Context#getSystemService([Link]<T>))
WINDOW_SERVICE (/reference/android/content/Context#WINDOW_SERVICE)
[Link] 149/302
2/15/26, 8:49 PM Context | API reference | Android Developers
LAYOUT_INFLATER_SERVICE (/reference/android/content/Context#LAYOUT_INFLATER_SERVICE)
WALLPAPER_SERVICE (/reference/android/content/Context#WALLPAPER_SERVICE)
createWindowContext
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
[Link].TYPE_BASE_APPLICATION
(/reference/android/view/[Link]#TYPE_B
[Link].TYPE_APPLICATION
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_STARTI
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_DRAWN_APPLICATION
(/reference/android/view/[Link]#TYPE_D
[Link] 150/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link].TYPE_APPLICATION_PANEL
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_MEDIA
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_SUB_PA
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_APPLICATION_ATTACH
(/reference/android/view/[Link]#TYPE_A
[Link].TYPE_STATUS_BAR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_SEARCH_BAR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_PHONE
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_SYSTEM_ALERT
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_TOAST
(/reference/android/view/[Link]#TYPE_T
[Link].TYPE_SYSTEM_OVERLAY
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_PRIORITY_PHONE
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_SYSTEM_DIALOG
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_KEYGUARD_DIALOG
(/reference/android/view/[Link]#TYPE_K
[Link].TYPE_SYSTEM_ERROR
(/reference/android/view/[Link]#TYPE_S
[Link].TYPE_INPUT_METHOD
(/reference/android/view/[Link]#TYPE_IN
[Link].TYPE_INPUT_METHOD_DIALO
(/reference/android/view/[Link]#TYPE_IN
[Link].TYPE_WALLPAPER
(/reference/android/view/[Link]#TYPE_W
[Link].TYPE_PRIVATE_PRESENTATI
(/reference/android/view/[Link]#TYPE_P
[Link].TYPE_ACCESSIBILITY_OVER
(/reference/android/view/[Link]#TYPE_A
[Link] 151/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link].TYPE_APPLICATION_OVERLA
(/reference/android/view/[Link]#TYPE_A
Returns
Throws
See also:
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
getSystemService(Class)
(/reference/android/content/Context#getSystemService([Link]<T>))
WINDOW_SERVICE (/reference/android/content/Context#WINDOW_SERVICE)
LAYOUT_INFLATER_SERVICE (/reference/android/content/Context#LAYOUT_INFLATER_SERVICE)
WALLPAPER_SERVICE (/reference/android/content/Context#WALLPAPER_SERVICE)
[Link] 152/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns an array of strings naming the private databases associated with this Context's
application package.
Returns
See also:
deleteDatabase(String) (/reference/android/content/Context#deleteDatabase([Link]))
Parameters
[Link] 153/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
See also:
Delete the given private file associated with this Context's application package.
Parameters
name String : The name of the file to delete; can not contain path
separators.
Returns
See also:
openFileInput(String) (/reference/android/content/Context#openFileInput([Link]))
[Link] 154/302
2/15/26, 8:49 PM Context | API reference | Android Developers
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
fileList() (/reference/android/content/Context#fileList())
[Link]() (/reference/java/io/File#delete())
deleteSharedPreferences
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
Returns
boolean true if the shared preferences file was successfully deleted; else
false .
See also:
getSharedPreferences(String, int)
(/reference/android/content/Context#getSharedPreferences([Link],%20int))
enforceCallingOrSelfPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 155/302
2/15/26, 8:49 PM Context | API reference | Android Developers
If neither you nor the calling process of an IPC you are handling has been granted a
particular permission, throw a SecurityException (/reference/java/lang/SecurityException) .
This is the same as enforceCallingPermission(String, String)
(/reference/android/content/Context#enforceCallingPermission([Link],%[Link])) ,
except it grants your own permissions if you are not currently processing an IPC. Use with
care!
Parameters
See also:
checkCallingOrSelfPermission(String)
(/reference/android/content/Context#checkCallingOrSelfPermission([Link]))
enforceCallingOrSelfUriPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
If the calling process of an IPC or you has not been granted permission to access a
specific URI, throw SecurityException (/reference/java/lang/SecurityException) . This is the
[Link] 156/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
See also:
checkCallingOrSelfUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingOrSelfUriPermission([Link],%20int))
enforceCallingPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
If the calling process of an IPC you are handling has not been granted a particular
permission, throw a SecurityException (/reference/java/lang/SecurityException) . This is
[Link] 157/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
See also:
checkCallingPermission(String)
(/reference/android/content/Context#checkCallingPermission([Link]))
enforceCallingUriPermission
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 158/302
2/15/26, 8:49 PM Context | API reference | Android Developers
If the calling process and uid has not been granted permission to access a specific URI,
throw SecurityException (/reference/java/lang/SecurityException) . This is basically the same
as calling enforceUriPermission([Link], int, int, int,
[Link])
(/reference/android/content/Context#enforceUriPermission([Link],%20int,%20int,%20int,%2
[Link]))
with the pid and uid returned by [Link]()
(/reference/android/os/Binder#getCallingPid()) and [Link]()
(/reference/android/os/Binder#getCallingUid()) . One important difference is that if you are not
currently processing an IPC, this function will always throw a SecurityException.
Parameters
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
See also:
checkCallingUriPermission(Uri, int)
(/reference/android/content/Context#checkCallingUriPermission([Link],%20int))
[Link] 159/302
2/15/26, 8:49 PM Context | API reference | Android Developers
int uid,
String (/reference/java/lang/String) message)
If the given permission is not allowed for a particular process and user ID running in the
system, throw a SecurityException (/reference/java/lang/SecurityException) .
Parameters
uid int : The UID being checked against. A uid of 0 is the root user,
which will pass every permission check.
See also:
[Link] 160/302
2/15/26, 8:49 PM Context | API reference | Android Developers
int modeFlags,
String (/reference/java/lang/String) message)
Enforce both a Uri and normal permission. This allows you to perform both
enforcePermission(String, int, int, String)
(/reference/android/content/Context#enforcePermission([Link],%20int,%20int,%[Link].
String))
and enforceUriPermission(Uri, int, int, int, String)
(/reference/android/content/Context#enforceUriPermission([Link],%20int,%20int,%20int,%2
[Link]))
in one call.
Parameters
uri Uri : The Uri whose permission is to be checked, or null to not do this
readPermission String : The permission that provides overall read access, or null to n
this check.
writePermission String : The permission that provides overall write access, or null to
this check.
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
[Link] 161/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
If a particular process and uid has not been granted permission to access a specific URI,
throw SecurityException (/reference/java/lang/SecurityException) . This only checks for
permissions that have been explicitly granted -- if the given process/uid has more general
access to the URI's content provider then this check will always fail.
Parameters
uid int : The UID being checked against. A uid of 0 is the root user, which
every permission check.
[Link] 162/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
See also:
Returns an array of strings naming the private files associated with this Context's
application package.
Returns
See also:
openFileInput(String) (/reference/android/content/Context#openFileInput([Link]))
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
[Link] 163/302
2/15/26, 8:49 PM Context | API reference | Android Developers
deleteFile(String) (/reference/android/content/Context#deleteFile([Link]))
getApplicationContext
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return the context of the single, global Application object of the current process. This
generally should only be used if you need a Context whose lifecycle is separate from the
current context, that is tied to the lifetime of the process rather than the current
component.
If used from an Activity context, the receiver is being registered within that activity.
This means that you are expected to unregister before the activity is done being
destroyed; in fact if you do not do so, the framework will clean up your leaked
registration as it removes the activity and log an error. Thus, if you use the Activity
context to register a receiver that is static (global to the process, not associated
with an Activity instance) then that registration will be removed on you at whatever
point the activity you used is destroyed.
If used from the Context returned here, the receiver is being registered with the
global state associated with your application. Thus it will never be unregistered for
you. This is necessary if the receiver is associated with static data, not a particular
component. However using the ApplicationContext elsewhere can easily lead to
serious leaks if you forget to unregister, unbind, etc.
Returns
Context
(/reference/android/content/Context)
[Link] 164/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
ApplicationInfo
(/reference/android/content/pm/ApplicationInfo)
Returns
See also:
getResources() (/reference/android/content/Context#getResources())
[Link] 165/302
2/15/26, 8:49 PM Context | API reference | Android Developers
getAttributionSource
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Returns
See also:
AttributionSource (/reference/android/content/AttributionSource)
Attribution can be used in complex apps to logically separate parts of the app. E.g. a
blogging app might also have a instant messaging app built in. In this case two separate
tags can for used each sub-feature.
Returns
String the attribution tag this context is for or null if this is the default.
(/reference/java/lang/String)
[Link] 166/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns the absolute path to the application specific cache directory on the filesystem.
The system will automatically delete files in this directory as disk space is needed
elsewhere on the device. The system will always delete older files first, as reported by
[Link]() (/reference/java/io/File#lastModified()) . If desired, you can exert more
control over how files are deleted using
[Link](File, boolean)
(/reference/android/os/storage/StorageManager#setCacheBehaviorGroup([Link],%20boolean))
and [Link](File, boolean)
(/reference/android/os/storage/StorageManager#setCacheBehaviorTombstone([Link],%20boolea
n))
.
Apps are strongly encouraged to keep their usage of cache space below the quota
returned by [Link]([Link])
(/reference/android/os/storage/StorageManager#getCacheQuotaBytes([Link])) . If your app
goes above this quota, your cached files will be some of the first to be deleted when
additional disk space is needed. Conversely, if your app stays under this quota, your
cached files will be some of the last to be deleted when additional disk space is needed.
Note that your cache quota will change over time depending on how frequently the user
interacts with your app, and depending on how much system-wide disk space is used.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
Apps require no extra permissions to read or write to the returned path, since this path
lives in their private storage.
Returns
File (/reference/java/io/File) The path of the directory holding application cache files.
See also:
[Link] 167/302
2/15/26, 8:49 PM Context | API reference | Android Developers
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
getFileStreamPath(String)
(/reference/android/content/Context#getFileStreamPath([Link]))
getExternalCacheDir() (/reference/android/content/Context#getExternalCacheDir())
Return a class loader you can use to retrieve classes in this package.
Returns
ClassLoader
(/reference/java/lang/ClassLoader)
Returns the absolute path to the application specific cache directory on the filesystem
designed for storing cached code.
The system will delete any files stored in this location both when your specific application
is upgraded, and when the entire platform is upgraded.
[Link] 168/302
2/15/26, 8:49 PM Context | API reference | Android Developers
This location is optimal for storing compiled or optimized code generated by your
application at runtime.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
Apps require no extra permissions to read or write to the returned path, since this path
lives in their private storage.
Returns
File (/reference/java/io/File) The path of the directory holding application code cache files.
Returns a color associated with a particular resource ID and styled for the current theme.
Parameters
Returns
[Link] 169/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
Returns a color state list associated with a particular resource ID and styled for the
current theme.
Parameters
Returns
Throws
[Link] 170/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
ContentResolver
(/reference/android/content/ContentResolver)
Returns the absolute path to the directory on the filesystem where all private files
belonging to this app are stored. Apps should not use this path directly; they should
instead use getFilesDir() (/reference/android/content/Context#getFilesDir()) , getCacheDir()
(/reference/android/content/Context#getCacheDir()) , getDir([Link], int)
(/reference/android/content/Context#getDir([Link],%20int)) , or other storage APIs on
this class.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
No additional permissions are required for the calling app to read or write files under the
returned path.
Returns
[Link] 171/302
2/15/26, 8:49 PM Context | API reference | Android Developers
File (/reference/java/io/File)
See also:
[Link] (/reference/android/content/pm/ApplicationInfo#dataDir)
Returns the absolute path on the filesystem where a database created with
openOrCreateDatabase(String, int, CursorFactory)
(/reference/android/content/Context#openOrCreateDatabase([Link],%20int,%[Link]
[Link]))
is stored.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
Parameters
name String : The name of the database for which you would like to get
its path.
Returns
See also:
[Link] 172/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Gets the device ID this context is associated with. Applications can use this method to
determine whether they are running on a virtual device and identify that device. The
device ID of the host device is Context.DEVICE_ID_DEFAULT
(/reference/android/content/Context#DEVICE_ID_DEFAULT)
If the underlying device ID is changed by the system, for example, when an Activity
(/reference/android/app/Activity) is moved to a different virtual device, applications can
register to listen to changes by calling
[Link](Executor, IntConsumer)
(/reference/android/content/Context#registerDeviceIdChangeListener([Link],%
[Link]))
.
This method will only return a reliable value for this instance if it was created with
[Link](int)
(/reference/android/content/Context#createDeviceContext(int)) , or if this instance is a UI or
Display Context. Contexts created with [Link](int)
(/reference/android/content/Context#createDeviceContext(int)) will have an explicit device
association, which will never change, even if the underlying device is closed or is
removed. UI Contexts and Display Contexts are already associated with a display, so if the
device association is not explicitly given, [Link]()
(/reference/android/content/Context#getDeviceId()) will return the ID of the device associated
with the associated display. The system can assign an arbitrary device id value for
Contexts not logically associated with a device.
Returns
[Link] 173/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
createDeviceContext(int) (/reference/android/content/Context#createDeviceContext(int))
registerDeviceIdChangeListener(Executor, IntConsumer)
(/reference/android/content/Context#registerDeviceIdChangeListener([Link],%
[Link]))
isUiContext() (/reference/android/content/Context#isUiContext())
Retrieve, creating if needed, a new directory in which the application can place its own
custom data files. You can use the returned File object to create and access files in this
directory. Note that files created through a File object will only be accessible by your own
application; you can only set the mode of the entire directory, not of individual files.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
Apps require no extra permissions to read or write to the returned path, since this path
lives in their private storage.
Parameters
[Link] 174/302
2/15/26, 8:49 PM Context | API reference | Android Developers
MODE_PRIVATE
(/reference/android/content/Context#MODE_PRIVATE)
MODE_WORLD_READABLE
(/reference/android/content/Context#MODE_WORLD_READABLE)
MODE_WORLD_WRITEABLE
(/reference/android/content/Context#MODE_WORLD_WRITEABLE)
MODE_APPEND
(/reference/android/content/Context#MODE_APPEND)
Returns
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
Get the display this context is associated with. Applications should use this method with
Activity (/reference/android/app/Activity) or a context associated with a Display
(/reference/android/view/Display) via createDisplayContext([Link])
(/reference/android/content/Context#createDisplayContext([Link])) to get a display
object associated with a Context, or [Link](int)
(/reference/android/hardware/display/DisplayManager#getDisplay(int)) to get a display object by
id.
[Link] 175/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
Throws
Returns a drawable object associated with a particular resource ID and styled for the
current theme.
Parameters
Returns
[Link] 176/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
The platform does not always monitor the space available in shared storage, and
thus may not automatically delete these files. Apps should always manage the
maximum space used in this location. Currently the only time files here will be
deleted by the platform is when running on Build.VERSION_CODES.JELLY_BEAN_MR1
(/reference/android/os/Build.VERSION_CODES#JELLY_BEAN_MR1) or later and
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link])) returns true.
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
[Link] 177/302
2/15/26, 8:49 PM Context | API reference | Android Developers
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
Starting in Build.VERSION_CODES.KITKAT
(/reference/android/os/Build.VERSION_CODES#KITKAT) , no permissions are required to read or
write to the returned path; it's always accessible to the calling app. This only applies to
paths generated for package name of the calling application. To access paths belonging
to other packages, [Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) and/or
[Link].READ_EXTERNAL_STORAGE
(/reference/android/[Link]#READ_EXTERNAL_STORAGE) are required.
The returned path may change over time if different shared storage media is inserted, so
only relative paths should be persisted.
Returns
File (/reference/java/io/File) the absolute path to application-specific directory. May return null
if shared storage is not currently available.
See also:
getCacheDir() (/reference/android/content/Context#getCacheDir())
getExternalCacheDirs() (/reference/android/content/Context#getExternalCacheDirs())
[Link] 178/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
getExternalCacheDirs
Added in API level 19 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
The platform does not always monitor the space available in shared storage, and
thus may not automatically delete these files. Apps should always manage the
maximum space used in this location. Currently the only time files here will be
deleted by the platform is when running on Build.VERSION_CODES.JELLY_BEAN_MR1
(/reference/android/os/Build.VERSION_CODES#JELLY_BEAN_MR1) or later and
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link])) returns true.
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
[Link] 179/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Shared storage devices returned here are considered a stable part of the device,
including physical media slots under a protective cover. The returned paths do not include
transient devices, such as USB flash drives connected to handheld devices.
An application may store data on any or all of the returned devices. For example, an app
may choose to store large files on the device with the most available space, as measured
by StatFs (/reference/android/os/StatFs) .
No additional permissions are required for the calling app to read or write files under the
returned path. Write access outside of these paths on secondary external storage devices
is not available.
The returned paths may change over time if different shared storage media is inserted, so
only relative paths should be persisted.
Returns
See also:
getExternalCacheDir() (/reference/android/content/Context#getExternalCacheDir())
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link] 180/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
Returns the absolute path to the directory on the primary shared/external storage device
where the application can place persistent files it owns. These files are internal to the
applications, and not typically visible to the user as media.
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
Starting in Build.VERSION_CODES.KITKAT
(/reference/android/os/Build.VERSION_CODES#KITKAT) , no permissions are required to read or
write to the returned path; it's always accessible to the calling app. This only applies to
paths generated for package name of the calling application. To access paths belonging
to other packages, [Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) and/or
[Link] 181/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link].READ_EXTERNAL_STORAGE
(/reference/android/[Link]#READ_EXTERNAL_STORAGE) are required.
The returned path may change over time if different shared storage media is inserted, so
only relative paths should be persisted.
void createExternalStoragePrivateFile() {
// Create a path where we will place our private file on external
// storage.
File file = new File(getExternalFilesDir(null), "[Link]");
try {
// Very simple code to copy a picture from the application's
// resource into the external file. Note that this code does
// no error checking, and assumes the picture is small (does not
// try to copy it in chunks). Note that if external storage is
// not currently mounted this will silently fail.
InputStream is = getResources().openRawResource([Link]);
OutputStream os = new FileOutputStream(file);
byte[] data = new byte[[Link]()];
[Link](data);
[Link](data);
[Link]();
[Link]();
} catch (IOException e) {
// Unable to create file, likely because external storage is
// not currently mounted.
Log.w("ExternalStorage", "Error writing " + file, e);
}
}
void deleteExternalStoragePrivateFile() {
// Get path for the file on external storage. If external
// storage is not currently mounted this will fail.
File file = new File(getExternalFilesDir(null), "[Link]");
[Link]();
}
boolean hasExternalStoragePrivateFile() {
// Get path for the file on external storage. If external
[Link] 182/302
2/15/26, 8:49 PM Context | API reference | Android Developers
If you supply a non-null type to this function, the returned file will be a path to a sub-
directory of the given type. Though these files are not automatically scanned by the
media scanner, you can explicitly add them to the media database with
[Link]
(/reference/android/media/MediaScannerConnection#scanFile([Link],%[Link].
String[],%[Link][],%[Link]
r))
. Note that this is not the same as
[Link]()
(/reference/android/os/Environment#getExternalStoragePublicDirectory([Link])) , which
provides directories of media shared by all applications. The directories returned here are
owned by the application, and their contents will be removed when the application is
uninstalled. Unlike [Link]()
(/reference/android/os/Environment#getExternalStoragePublicDirectory([Link])) , the
directory returned here will be automatically created for you.
void createExternalStoragePrivatePicture() {
// Create a path where we will place our picture in our own private
// pictures directory. Note that we don't really need to place a
// picture in DIRECTORY_PICTURES, since the media scanner will see
// all media in these directories; this may be useful with other
// media types such as DIRECTORY_MUSIC however to help it classify
// your media for display to the user.
File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File file = new File(path, "[Link]");
try {
// Very simple code to copy a picture from the application's
// resource into the external file. Note that this code does
// no error checking, and assumes the picture is small (does not
// try to copy it in chunks). Note that if external storage is
// not currently mounted this will silently fail.
InputStream is = getResources().openRawResource([Link]);
OutputStream os = new FileOutputStream(file);
[Link] 183/302
2/15/26, 8:49 PM Context | API reference | Android Developers
void deleteExternalStoragePrivatePicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and delete the file. If external
// storage is not currently mounted this will fail.
File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (path != null) {
File file = new File(path, "[Link]");
[Link]();
}
}
boolean hasExternalStoragePrivatePicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and check if the file exists. If
// external storage is not currently mounted this will think the
// picture doesn't exist.
File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (path != null) {
File file = new File(path, "[Link]");
return [Link]();
}
return false;
}
[Link] 184/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
type String : The type of files directory to return. May be null for the
root of the files directory or one of the following constants for a
subdirectory: Environment.DIRECTORY_MUSIC
(/reference/android/os/Environment#DIRECTORY_MUSIC),
Environment.DIRECTORY_PODCASTS
(/reference/android/os/Environment#DIRECTORY_PODCASTS),
Environment.DIRECTORY_RINGTONES
(/reference/android/os/Environment#DIRECTORY_RINGTONES),
Environment.DIRECTORY_ALARMS
(/reference/android/os/Environment#DIRECTORY_ALARMS),
Environment.DIRECTORY_NOTIFICATIONS
(/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS),
Environment.DIRECTORY_PICTURES
(/reference/android/os/Environment#DIRECTORY_PICTURES), or
Environment.DIRECTORY_MOVIES
(/reference/android/os/Environment#DIRECTORY_MOVIES).
Returns
File (/reference/java/io/File) the absolute path to application-specific directory. May return null
if shared storage is not currently available.
See also:
getFilesDir() (/reference/android/content/Context#getFilesDir())
getExternalFilesDirs(String)
(/reference/android/content/Context#getExternalFilesDirs([Link]))
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
[Link] 185/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
Shared storage devices returned here are considered a stable part of the device,
including physical media slots under a protective cover. The returned paths do not include
transient devices, such as USB flash drives connected to handheld devices.
An application may store data on any or all of the returned devices. For example, an app
may choose to store large files on the device with the most available space, as measured
by StatFs (/reference/android/os/StatFs) .
No additional permissions are required for the calling app to read or write files under the
returned path. Write access outside of these paths on secondary external storage devices
is not available.
[Link] 186/302
2/15/26, 8:49 PM Context | API reference | Android Developers
The returned path may change over time if different shared storage media is inserted, so
only relative paths should be persisted.
Parameters
type String : The type of files directory to return. May be null for the
root of the files directory or one of the following constants for a
subdirectory: Environment.DIRECTORY_MUSIC
(/reference/android/os/Environment#DIRECTORY_MUSIC),
Environment.DIRECTORY_PODCASTS
(/reference/android/os/Environment#DIRECTORY_PODCASTS),
Environment.DIRECTORY_RINGTONES
(/reference/android/os/Environment#DIRECTORY_RINGTONES),
Environment.DIRECTORY_ALARMS
(/reference/android/os/Environment#DIRECTORY_ALARMS),
Environment.DIRECTORY_NOTIFICATIONS
(/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS),
Environment.DIRECTORY_PICTURES
(/reference/android/os/Environment#DIRECTORY_PICTURES), or
Environment.DIRECTORY_MOVIES
(/reference/android/os/Environment#DIRECTORY_MOVIES).
Returns
See also:
getExternalFilesDir(String)
(/reference/android/content/Context#getExternalFilesDir([Link]))
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link] 187/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
getExternalMediaDirs
Added in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
[Link] 188/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Shared storage devices returned here are considered a stable part of the device,
including physical media slots under a protective cover. The returned paths do not include
transient devices, such as USB flash drives connected to handheld devices.
An application may store data on any or all of the returned devices. For example, an app
may choose to store large files on the device with the most available space, as measured
by StatFs (/reference/android/os/StatFs) .
No additional permissions are required for the calling app to read or write files under the
returned path. Write access outside of these paths on secondary external storage devices
is not available.
The returned paths may change over time if different shared storage media is inserted, so
only relative paths should be persisted.
Returns
See also:
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
[Link] 189/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns the absolute path on the filesystem where a file created with
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int)) is stored.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
Parameters
name String : The name of the file for which you would like to get its path.
Returns
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
getFilesDir() (/reference/android/content/Context#getFilesDir())
Returns the absolute path to the directory on the filesystem where files created with
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int)) are stored.
[Link] 190/302
2/15/26, 8:49 PM Context | API reference | Android Developers
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
No additional permissions are required for the calling app to read or write files under the
returned path.
Returns
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
getFileStreamPath(String)
(/reference/android/content/Context#getFileStreamPath([Link]))
Returns
Executor
(/reference/java/util/concurrent/Executor)
[Link] 191/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Return the Looper for the main thread of the current process. This is the thread used to
dispatch calls to application components (activities, services, etc).
By definition, this method returns the same result as would be obtained by calling
[Link]() (/reference/android/os/Looper#getMainLooper()) .
Returns
Returns the absolute path to the directory on the filesystem similar to getFilesDir()
(/reference/android/content/Context#getFilesDir()) . The difference is that files placed under this
directory will be excluded from automatic backup to remote storage. See BackupAgent
(/reference/android/app/backup/BackupAgent) for a full discussion of the automatic backup
mechanism in Android.
The returned path may change over time if the calling app is moved to an adopted
storage device, so only relative paths should be persisted.
No additional permissions are required for the calling app to read or write files under the
returned path.
[Link] 192/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
File (/reference/java/io/File) The path of the directory holding application files that will not be
automatically backed up to remote storage.
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
getFileStreamPath(String)
(/reference/android/content/Context#getFileStreamPath([Link]))
BackupAgent (/reference/android/app/backup/BackupAgent)
Return the primary shared/external storage directory where this application's OBB files (if
there are any) can be found. Note if the application does not have any OBB files, this
directory may not exist.
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
[Link] 193/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Starting in Build.VERSION_CODES.KITKAT
(/reference/android/os/Build.VERSION_CODES#KITKAT) , no permissions are required to read or
write to the path that this method returns. However, starting from
Build.VERSION_CODES.M (/reference/android/os/Build.VERSION_CODES#M) , to read the OBB
expansion files, you must declare the [Link].READ_EXTERNAL_STORAGE
(/reference/android/[Link]#READ_EXTERNAL_STORAGE) permission in the app
manifest and ask for permission at runtime as follows:
<uses-permission android:name="[Link].READ_EXTERNAL_STORAGE"
android:maxSdkVersion="23" />
try {
BufferedReader br = new BufferedReader(new FileReader(obb));
open_failed = false;
ReadObbFile(br);
} catch (IOException e) {
open_failed = true;
}
if (open_failed) {
// request READ_EXTERNAL_STORAGE permission before reading OBB file
ReadObbFileWithPermission();
}
[Link] 194/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
File (/reference/java/io/File) the absolute path to application-specific directory. May return null
if shared storage is not currently available.
See also:
getObbDirs() (/reference/android/content/Context#getObbDirs())
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
[Link] 195/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Shared storage may not always be available, since removable media can be ejected
by the user. Media state can be checked using
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link])) .
There is no security enforced with these files. For example, any application holding
[Link].WRITE_EXTERNAL_STORAGE
(/reference/android/[Link]#WRITE_EXTERNAL_STORAGE) can write to these
files.
Shared storage devices returned here are considered a stable part of the device,
including physical media slots under a protective cover. The returned paths do not include
transient devices, such as USB flash drives connected to handheld devices.
An application may store data on any or all of the returned devices. For example, an app
may choose to store large files on the device with the most available space, as measured
by StatFs (/reference/android/os/StatFs) .
No additional permissions are required for the calling app to read or write files under the
returned path. Write access outside of these paths on secondary external storage devices
is not available.
Returns
See also:
getObbDir() (/reference/android/content/Context#getObbDir())
[Link](File)
(/reference/android/os/Environment#getExternalStorageState([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageEmulated([Link]))
[Link](File)
(/reference/android/os/Environment#isExternalStorageRemovable([Link]))
[Link] 196/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
getPackageCodePath
Added in API level 8 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Return the full path to this context's primary Android package. The Android package is a
ZIP file which contains application's primary code and assets.
Note: this is not generally useful for applications, since they should not be directly
accessing the file system.
Returns
[Link] 197/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
PackageManager
(/reference/android/content/pm/PackageManager)
Returns
String
(/reference/java/lang/String)
getPackageResourcePath
Added in API level 8 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 198/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Return the full path to this context's primary Android package. The Android package is a
ZIP file which contains the application's primary resources.
Note: this is not generally useful for applications, since they should not be directly
accessing the file system.
Returns
Return the set of parameters which this Context was created with, if it was created via
createContext([Link])
(/reference/android/content/Context#createContext([Link])) .
Returns
[Link] 199/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
See also:
getAssets() (/reference/android/content/Context#getAssets())
getSharedPreferences
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Retrieve and hold the contents of the preferences file 'name', returning a
SharedPreferences through which you can retrieve and modify its values. Only one
instance of the SharedPreferences object is returned to any callers for the same name,
meaning they will see each other's edits as soon as they are made.
If the preferences directory does not already exist, it will be created when this method is
called.
If a preferences file by this name does not exist, it will be created when you retrieve an
editor ( [Link]() (/reference/android/content/SharedPreferences#edit()) )
and then commit changes ( [Link]()
(/reference/android/content/[Link]#commit()) or
[Link]()
(/reference/android/content/[Link]#apply()) ).
[Link] 200/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
MODE_PRIVATE
(/reference/android/content/Context#MODE_PRIVATE)
MODE_WORLD_READABLE
(/reference/android/content/Context#MODE_WORLD_READABLE)
MODE_WORLD_WRITEABLE
(/reference/android/content/Context#MODE_WORLD_WRITEABLE)
MODE_MULTI_PROCESS
(/reference/android/content/Context#MODE_MULTI_PROCESS)
Returns
See also:
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIVATE)
[Link] 201/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns a localized string from the application's package's default string table.
Parameters
Returns
String The string data associated with the resource, stripped of styled text
(/reference/java/lang/String) information.
This value cannot be null .
Returns a localized formatted string from the application's package's default string table,
substituting the format arguments as defined in Formatter (/reference/java/util/Formatter)
and [Link](String, Object)
(/reference/java/lang/String#format([Link],%[Link][])) .
Parameters
formatArgs Object : The format arguments that will be used for substitution.
[Link] 202/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
String The string data associated with the resource, formatted and stripped
(/reference/java/lang/String) of styled text information.
This value cannot be null .
[Link] 203/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Note: System services obtained via this API may be closely associated with the Context in
which they are obtained from. In general, do not share the service objects between
various different contexts (Activities, Applications, Services, Providers, etc.)
Parameters
Returns
[Link] 204/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Return the handle to a system-level service by name. The class of the returned object
varies by the requested name. Currently available names are:
The top-level window manager in which you can place custom windows. The
returned object is a WindowManager (/reference/android/view/WindowManager) . Must
only be obtained from a visual context such as Activity or a Context created with
createWindowContext(int, [Link])
(/reference/android/content/Context#createWindowContext(int,%[Link])) , which
are adjusted to the configuration and visual bounds of an area on screen.
LAYOUT_INFLATER_SERVICE (/reference/android/content/Context#LAYOUT_INFLATER_SERVICE)
("layout_inflater")
[Link] 205/302
2/15/26, 8:49 PM Context | API reference | Android Developers
NOTIFICATION_SERVICE (/reference/android/content/Context#NOTIFICATION_SERVICE)
("notification")
VIBRATOR_MANAGER_SERVICE
(/reference/android/content/Context#VIBRATOR_MANAGER_SERVICE) ("vibrator_manager")
CONNECTIVITY_SERVICE (/reference/android/content/Context#CONNECTIVITY_SERVICE)
("connectivity")
[Link] 206/302
2/15/26, 8:49 PM Context | API reference | Android Developers
INPUT_METHOD_SERVICE (/reference/android/content/Context#INPUT_METHOD_SERVICE)
("input_method")
BATTERY_SERVICE (/reference/android/content/Context#BATTERY_SERVICE)
("batterymanager")
JOB_SCHEDULER_SERVICE (/reference/android/content/Context#JOB_SCHEDULER_SERVICE)
("taskmanager")
NETWORK_STATS_SERVICE (/reference/android/content/Context#NETWORK_STATS_SERVICE)
("netstats")
[Link] 207/302
2/15/26, 8:49 PM Context | API reference | Android Developers
HARDWARE_PROPERTIES_SERVICE
(/reference/android/content/Context#HARDWARE_PROPERTIES_SERVICE)
("hardware_properties")
DOMAIN_VERIFICATION_SERVICE
(/reference/android/content/Context#DOMAIN_VERIFICATION_SERVICE) ("domain_verification")
A DomainVerificationManager
(/reference/android/content/pm/verify/domain/DomainVerificationManager) for accessing
web domain approval state.
DISPLAY_HASH_SERVICE (/reference/android/content/Context#DISPLAY_HASH_SERVICE)
("display_hash")
A
ERROR(/[Link]
er) (/) for managing authentication related policies on the device.
Note: System services obtained via this API may be closely associated with the Context in
which they are obtained from. In general, do not share the service objects between
various different contexts (Activities, Applications, Services, Providers, etc.)
[Link] 208/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Note: When implementing this method, keep in mind that new services can be added on
newer Android releases, so if you're looking for just the explicit names mentioned above,
make sure to return null when you don't recognize the name — if you throw a
RuntimeException (/reference/java/lang/RuntimeException) exception instead, your app might
break on new Android releases.
Parameters
POWER_SERVICE (/reference/android/content/Context#POWER_SE
WINDOW_SERVICE (/reference/android/content/Context#WINDOW
LAYOUT_INFLATER_SERVICE
(/reference/android/content/Context#LAYOUT_INFLATER_SERVICE
ACCOUNT_SERVICE (/reference/android/content/Context#ACCOU
ACTIVITY_SERVICE (/reference/android/content/Context#ACTIVI
ALARM_SERVICE (/reference/android/content/Context#ALARM_SE
NOTIFICATION_SERVICE
(/reference/android/content/Context#NOTIFICATION_SERVICE)
ACCESSIBILITY_SERVICE
(/reference/android/content/Context#ACCESSIBILITY_SERVICE)
CAPTIONING_SERVICE
(/reference/android/content/Context#CAPTIONING_SERVICE)
KEYGUARD_SERVICE
(/reference/android/content/Context#KEYGUARD_SERVICE)
LOCATION_SERVICE
(/reference/android/content/Context#LOCATION_SERVICE)
HEALTHCONNECT_SERVICE
(/reference/android/content/Context#HEALTHCONNECT_SERVICE
SEARCH_SERVICE (/reference/android/content/Context#SEARCH_
SENSOR_SERVICE (/reference/android/content/Context#SENSOR_
STORAGE_SERVICE (/reference/android/content/Context#STORAG
[Link] 209/302
2/15/26, 8:49 PM Context | API reference | Android Developers
STORAGE_STATS_SERVICE
(/reference/android/content/Context#STORAGE_STATS_SERVICE)
WALLPAPER_SERVICE
(/reference/android/content/Context#WALLPAPER_SERVICE)
VIBRATOR_MANAGER_SERVICE
(/reference/android/content/Context#VIBRATOR_MANAGER_SERV
VIBRATOR_SERVICE
(/reference/android/content/Context#VIBRATOR_SERVICE)
CONNECTIVITY_SERVICE
(/reference/android/content/Context#CONNECTIVITY_SERVICE)
TETHERING_SERVICE
(/reference/android/content/Context#TETHERING_SERVICE)
IPSEC_SERVICE (/reference/android/content/Context#IPSEC_SER
VPN_MANAGEMENT_SERVICE
(/reference/android/content/Context#VPN_MANAGEMENT_SERVIC
NETWORK_STATS_SERVICE
(/reference/android/content/Context#NETWORK_STATS_SERVICE)
WIFI_SERVICE (/reference/android/content/Context#WIFI_SERVIC
WIFI_AWARE_SERVICE
(/reference/android/content/Context#WIFI_AWARE_SERVICE)
WIFI_P2P_SERVICE (/reference/android/content/Context#WIFI_P
WIFI_RTT_RANGING_SERVICE
(/reference/android/content/Context#WIFI_RTT_RANGING_SERVIC
NSD_SERVICE (/reference/android/content/Context#NSD_SERVICE
AUDIO_SERVICE (/reference/android/content/Context#AUDIO_SE
BIOMETRIC_SERVICE
(/reference/android/content/Context#BIOMETRIC_SERVICE)
MEDIA_ROUTER_SERVICE
(/reference/android/content/Context#MEDIA_ROUTER_SERVICE)
TELEPHONY_SERVICE
(/reference/android/content/Context#TELEPHONY_SERVICE)
TELEPHONY_SUBSCRIPTION_SERVICE
(/reference/android/content/Context#TELEPHONY_SUBSCRIPTION
TELEPHONY_PHONE_NUMBER_SERVICE
(/reference/android/content/Context#TELEPHONY_PHONE_NUMB
CARRIER_CONFIG_SERVICE
(/reference/android/content/Context#CARRIER_CONFIG_SERVICE)
[Link] 210/302
2/15/26, 8:49 PM Context | API reference | Android Developers
EUICC_SERVICE (/reference/android/content/Context#EUICC_SER
TELECOM_SERVICE (/reference/android/content/Context#TELECO
CLIPBOARD_SERVICE
(/reference/android/content/Context#CLIPBOARD_SERVICE)
INPUT_METHOD_SERVICE
(/reference/android/content/Context#INPUT_METHOD_SERVICE)
TEXT_SERVICES_MANAGER_SERVICE
(/reference/android/content/Context#TEXT_SERVICES_MANAGER_
TEXT_CLASSIFICATION_SERVICE
(/reference/android/content/Context#TEXT_CLASSIFICATION_SER
APPWIDGET_SERVICE
(/reference/android/content/Context#APPWIDGET_SERVICE)
DROPBOX_SERVICE (/reference/android/content/Context#DROPBO
DEVICE_POLICY_SERVICE
(/reference/android/content/Context#DEVICE_POLICY_SERVICE)
UI_MODE_SERVICE (/reference/android/content/Context#UI_MOD
DOWNLOAD_SERVICE
(/reference/android/content/Context#DOWNLOAD_SERVICE)
NFC_SERVICE (/reference/android/content/Context#NFC_SERVICE
BLUETOOTH_SERVICE
(/reference/android/content/Context#BLUETOOTH_SERVICE)
USB_SERVICE (/reference/android/content/Context#USB_SERVICE
LAUNCHER_APPS_SERVICE
(/reference/android/content/Context#LAUNCHER_APPS_SERVICE)
INPUT_SERVICE (/reference/android/content/Context#INPUT_SER
DISPLAY_SERVICE (/reference/android/content/Context#DISPLAY
USER_SERVICE (/reference/android/content/Context#USER_SERV
RESTRICTIONS_SERVICE
(/reference/android/content/Context#RESTRICTIONS_SERVICE)
APP_OPS_SERVICE (/reference/android/content/Context#APP_OP
ROLE_SERVICE (/reference/android/content/Context#ROLE_SERV
CAMERA_SERVICE (/reference/android/content/Context#CAMERA_
PRINT_SERVICE (/reference/android/content/Context#PRINT_SER
CONSUMER_IR_SERVICE
(/reference/android/content/Context#CONSUMER_IR_SERVICE)
[Link] 211/302
2/15/26, 8:49 PM Context | API reference | Android Developers
TV_INTERACTIVE_APP_SERVICE
(/reference/android/content/Context#TV_INTERACTIVE_APP_SERV
TV_INPUT_SERVICE
(/reference/android/content/Context#TV_INPUT_SERVICE)
USAGE_STATS_SERVICE
(/reference/android/content/Context#USAGE_STATS_SERVICE)
MEDIA_SESSION_SERVICE
(/reference/android/content/Context#MEDIA_SESSION_SERVICE)
MEDIA_COMMUNICATION_SERVICE
(/reference/android/content/Context#MEDIA_COMMUNICATION_S
BATTERY_SERVICE (/reference/android/content/Context#BATTER
JOB_SCHEDULER_SERVICE
(/reference/android/content/Context#JOB_SCHEDULER_SERVICE)
PERSISTENT_DATA_BLOCK_SERVICE
(/reference/android/content/Context#PERSISTENT_DATA_BLOCK_
MEDIA_PROJECTION_SERVICE
(/reference/android/content/Context#MEDIA_PROJECTION_SERVI
MIDI_SERVICE (/reference/android/content/Context#MIDI_SERVIC
HARDWARE_PROPERTIES_SERVICE
(/reference/android/content/Context#HARDWARE_PROPERTIES_S
SHORTCUT_SERVICE
(/reference/android/content/Context#SHORTCUT_SERVICE)
SYSTEM_HEALTH_SERVICE
(/reference/android/content/Context#SYSTEM_HEALTH_SERVICE)
COMPANION_DEVICE_SERVICE
(/reference/android/content/Context#COMPANION_DEVICE_SERV
VIRTUAL_DEVICE_SERVICE
(/reference/android/content/Context#VIRTUAL_DEVICE_SERVICE)
CROSS_PROFILE_APPS_SERVICE
(/reference/android/content/Context#CROSS_PROFILE_APPS_SER
LOCALE_SERVICE (/reference/android/content/Context#LOCALE_
MEDIA_METRICS_SERVICE
(/reference/android/content/Context#MEDIA_METRICS_SERVICE)
DISPLAY_HASH_SERVICE
(/reference/android/content/Context#DISPLAY_HASH_SERVICE)
CREDENTIAL_SERVICE
(/reference/android/content/Context#CREDENTIAL_SERVICE)
[Link] 212/302
2/15/26, 8:49 PM Context | API reference | Android Developers
DEVICE_LOCK_SERVICE
(/reference/android/content/Context#DEVICE_LOCK_SERVICE)
GRAMMATICAL_INFLECTION_SERVICE
(/reference/android/content/Context#GRAMMATICAL_INFLECTION
SECURITY_STATE_SERVICE
(/reference/android/content/Context#SECURITY_STATE_SERVICE)
CONTACT_KEYS_SERVICE
(/reference/android/content/Context#CONTACT_KEYS_SERVICE)
MEDIA_QUALITY_SERVICE
(/reference/android/content/Context#MEDIA_QUALITY_SERVICE)
ADVANCED_PROTECTION_SERVICE
(/reference/android/content/Context#ADVANCED_PROTECTION_S
.
This value cannot be null .
Returns
See also:
WINDOW_SERVICE (/reference/android/content/Context#WINDOW_SERVICE)
WindowManager (/reference/android/view/WindowManager)
LAYOUT_INFLATER_SERVICE (/reference/android/content/Context#LAYOUT_INFLATER_SERVICE)
LayoutInflater (/reference/android/view/LayoutInflater)
ACTIVITY_SERVICE (/reference/android/content/Context#ACTIVITY_SERVICE)
ActivityManager (/reference/android/app/ActivityManager)
POWER_SERVICE (/reference/android/content/Context#POWER_SERVICE)
PowerManager (/reference/android/os/PowerManager)
ALARM_SERVICE (/reference/android/content/Context#ALARM_SERVICE)
[Link] 213/302
2/15/26, 8:49 PM Context | API reference | Android Developers
AlarmManager (/reference/android/app/AlarmManager)
NOTIFICATION_SERVICE (/reference/android/content/Context#NOTIFICATION_SERVICE)
NotificationManager (/reference/android/app/NotificationManager)
KEYGUARD_SERVICE (/reference/android/content/Context#KEYGUARD_SERVICE)
KeyguardManager (/reference/android/app/KeyguardManager)
LOCATION_SERVICE (/reference/android/content/Context#LOCATION_SERVICE)
LocationManager (/reference/android/location/LocationManager)
SEARCH_SERVICE (/reference/android/content/Context#SEARCH_SERVICE)
SearchManager (/reference/android/app/SearchManager)
SENSOR_SERVICE (/reference/android/content/Context#SENSOR_SERVICE)
SensorManager (/reference/android/hardware/SensorManager)
STORAGE_SERVICE (/reference/android/content/Context#STORAGE_SERVICE)
StorageManager (/reference/android/os/storage/StorageManager)
VIBRATOR_MANAGER_SERVICE
(/reference/android/content/Context#VIBRATOR_MANAGER_SERVICE)
VibratorManager (/reference/android/os/VibratorManager)
VIBRATOR_SERVICE (/reference/android/content/Context#VIBRATOR_SERVICE)
Vibrator (/reference/android/os/Vibrator)
CONNECTIVITY_SERVICE (/reference/android/content/Context#CONNECTIVITY_SERVICE)
ConnectivityManager (/reference/android/net/ConnectivityManager)
WIFI_SERVICE (/reference/android/content/Context#WIFI_SERVICE)
WifiManager (/reference/android/net/wifi/WifiManager)
AUDIO_SERVICE (/reference/android/content/Context#AUDIO_SERVICE)
AudioManager (/reference/android/media/AudioManager)
MEDIA_ROUTER_SERVICE (/reference/android/content/Context#MEDIA_ROUTER_SERVICE)
MediaRouter (/reference/android/media/MediaRouter)
TELEPHONY_SERVICE (/reference/android/content/Context#TELEPHONY_SERVICE)
[Link] 214/302
2/15/26, 8:49 PM Context | API reference | Android Developers
TelephonyManager (/reference/android/telephony/TelephonyManager)
TELEPHONY_SUBSCRIPTION_SERVICE
(/reference/android/content/Context#TELEPHONY_SUBSCRIPTION_SERVICE)
SubscriptionManager (/reference/android/telephony/SubscriptionManager)
CARRIER_CONFIG_SERVICE (/reference/android/content/Context#CARRIER_CONFIG_SERVICE)
CarrierConfigManager (/reference/android/telephony/CarrierConfigManager)
EUICC_SERVICE (/reference/android/content/Context#EUICC_SERVICE)
EuiccManager (/reference/android/telephony/euicc/EuiccManager)
INPUT_METHOD_SERVICE (/reference/android/content/Context#INPUT_METHOD_SERVICE)
InputMethodManager (/reference/android/view/inputmethod/InputMethodManager)
UI_MODE_SERVICE (/reference/android/content/Context#UI_MODE_SERVICE)
UiModeManager (/reference/android/app/UiModeManager)
DOWNLOAD_SERVICE (/reference/android/content/Context#DOWNLOAD_SERVICE)
DownloadManager (/reference/android/app/DownloadManager)
BATTERY_SERVICE (/reference/android/content/Context#BATTERY_SERVICE)
BatteryManager (/reference/android/os/BatteryManager)
JOB_SCHEDULER_SERVICE (/reference/android/content/Context#JOB_SCHEDULER_SERVICE)
JobScheduler (/reference/android/app/job/JobScheduler)
NETWORK_STATS_SERVICE (/reference/android/content/Context#NETWORK_STATS_SERVICE)
NetworkStatsManager (/reference/android/app/usage/NetworkStatsManager)
HardwarePropertiesManager (/reference/android/os/HardwarePropertiesManager)
HARDWARE_PROPERTIES_SERVICE
(/reference/android/content/Context#HARDWARE_PROPERTIES_SERVICE)
DOMAIN_VERIFICATION_SERVICE
(/reference/android/content/Context#DOMAIN_VERIFICATION_SERVICE)
DomainVerificationManager
(/reference/android/content/pm/verify/domain/DomainVerificationManager)
DISPLAY_HASH_SERVICE (/reference/android/content/Context#DISPLAY_HASH_SERVICE)
[Link] 215/302
2/15/26, 8:49 PM Context | API reference | Android Developers
DisplayHashManager (/reference/android/view/displayhash/DisplayHashManager)
ERROR(/#AUTHENTICATION_POLICY_SERVICE) (/)
ERROR(/[Link]) (/)
getSystemServiceName
Added in API level 23 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Gets the name of the system-level service that is represented by the specified class.
Parameters
Returns
String The service name or null if the class is not a supported system
(/reference/java/lang/String) service.
Return a localized, styled CharSequence from the application's package's default string
table.
[Link] 216/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
Returns
[Link]
(/reference/android/content/res/[Link])
[Link] 217/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
Drawable
(/reference/android/graphics/drawable/Drawable)
getWallpaperDesiredMinimumHeight
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 15 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Returns
int
getWallpaperDesiredMinimumWidth
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 15 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 218/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
int
Grant permission to access a specific Uri to another package, regardless of whether that
package has general permission to access the Uri's content provider. This can be used to
grant specific, temporary permissions, typically in response to user interaction (such as
the user opening an attachment that you would like someone else to display).
To succeed, the content provider owning the Uri must have set the grantUriPermissions
(/reference/android/[Link]#AndroidManifestProvider_grantUriPermissions) attribute in its
manifest or included the <grant-uri-permissions>
(/reference/android/[Link]#AndroidManifestGrantUriPermission) tag.
[Link] 219/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
toPackage String : The package you would like to allow to access the Uri.
uri Uri : The Uri you would like to grant access to.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_PERSISTABLE_U
Intent.FLAG_GRANT_PREFIX_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_PREFIX_URI_PE
See also:
revokeUriPermission(Uri, int)
(/reference/android/content/Context#revokeUriPermission([Link],%20int))
isDeviceProtectedStorage
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Indicates if the storage APIs of this Context are backed by device-protected storage.
Returns
[Link] 220/302
2/15/26, 8:49 PM Context | API reference | Android Developers
boolean
See also:
createDeviceProtectedStorageContext()
(/reference/android/content/Context#createDeviceProtectedStorageContext())
Returns
See also:
CONTEXT_RESTRICTED (/reference/android/content/Context#CONTEXT_RESTRICTED)
Returns true if the context is a UI context which can access UI components such as
WindowManager (/reference/android/view/WindowManager) , LayoutInflater
(/reference/android/view/LayoutInflater) or WallpaperManager
[Link] 221/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
boolean
See also:
getDisplay() (/reference/android/content/Context#getDisplay())
getSystemService(String)
(/reference/android/content/Context#getSystemService([Link]))
[Link]()
(/reference/android/os/[Link]#detectIncorrectContextUse())
Move an existing database file from the given source storage context to this context. This
is typically used to migrate data between storage locations after an upgrade, such as
migrating to device protected storage.
[Link] 222/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
sourceContext Context : The source context which contains the existing database
to move.
Returns
boolean true if the move was successful or if the database didn't exist in the
source context, otherwise false .
See also:
createDeviceProtectedStorageContext()
(/reference/android/content/Context#createDeviceProtectedStorageContext())
moveSharedPreferencesFrom
Added in API level 24 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Move an existing shared preferences file from the given source storage context to this
context. This is typically used to migrate data between storage locations after an upgrade,
such as moving to device protected storage.
Parameters
[Link] 223/302
2/15/26, 8:49 PM Context | API reference | Android Developers
sourceContext Context : The source context which contains the existing shared
preferences to move.
Returns
boolean true if the move was successful or if the shared preferences didn't
exist in the source context, otherwise false .
See also:
createDeviceProtectedStorageContext()
(/reference/android/content/Context#createDeviceProtectedStorageContext())
obtainStyledAttributes
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
[Link] 224/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
See also:
obtainStyledAttributes
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
[Link] 225/302
2/15/26, 8:49 PM Context | API reference | Android Developers
defStyleAttr int
defStyleRes int
Returns
See also:
obtainStyledAttributes
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
[Link] 226/302
2/15/26, 8:49 PM Context | API reference | Android Developers
resid int
Returns
Throws
[Link]
(/reference/android/content/res/[Link])
See also:
[Link](int, int[])
(/reference/android/content/res/[Link]#obtainStyledAttributes(int,%20int[]))
obtainStyledAttributes
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 227/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
See also:
[Link](int[])
(/reference/android/content/res/[Link]#obtainStyledAttributes(int[]))
Open a private file associated with this Context's application package for reading.
Parameters
name String : The name of the file to open; can not contain path
separators.
Returns
[Link] 228/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
FileNotFoundException
(/reference/java/io/FileNotFoundException)
See also:
openFileOutput(String, int)
(/reference/android/content/Context#openFileOutput([Link],%20int))
fileList() (/reference/android/content/Context#fileList())
deleteFile(String) (/reference/android/content/Context#deleteFile([Link]))
[Link](String)
(/reference/java/io/FileInputStream#FileInputStream([Link]))
Open a private file associated with this Context's application package for writing. Creates
the file if it doesn't already exist.
No additional permissions are required for the calling app to read or write the returned
file.
Parameters
[Link] 229/302
2/15/26, 8:49 PM Context | API reference | Android Developers
name String : The name of the file to open; can not contain path
separators.
MODE_PRIVATE
(/reference/android/content/Context#MODE_PRIVATE)
MODE_WORLD_READABLE
(/reference/android/content/Context#MODE_WORLD_READABLE)
MODE_WORLD_WRITEABLE
(/reference/android/content/Context#MODE_WORLD_WRITEABLE)
MODE_APPEND
(/reference/android/content/Context#MODE_APPEND)
Returns
Throws
FileNotFoundException
(/reference/java/io/FileNotFoundException)
See also:
MODE_APPEND (/reference/android/content/Context#MODE_APPEND)
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIVATE)
openFileInput(String) (/reference/android/content/Context#openFileInput([Link]))
fileList() (/reference/android/content/Context#fileList())
deleteFile(String) (/reference/android/content/Context#deleteFile([Link]))
[Link] 230/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link](String)
(/reference/java/io/FileOutputStream#FileOutputStream([Link]))
openOrCreateDatabase
Added in API level 11 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Open a new private SQLiteDatabase associated with this Context's application package.
Creates the database file if it doesn't exist.
Parameters
name String : The name (unique in the application package) of the databa
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIV
MODE_WORLD_READABLE
(/reference/android/content/Context#MODE_WORLD_READABLE)
MODE_WORLD_WRITEABLE
(/reference/android/content/Context#MODE_WORLD_WRITEABLE)
MODE_ENABLE_WRITE_AHEAD_LOGGING
(/reference/android/content/Context#MODE_ENABLE_WRITE_AHE
MODE_NO_LOCALIZED_COLLATORS
(/reference/android/content/Context#MODE_NO_LOCALIZED_COL
[Link] 231/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
Throws
See also:
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIVATE)
MODE_ENABLE_WRITE_AHEAD_LOGGING
(/reference/android/content/Context#MODE_ENABLE_WRITE_AHEAD_LOGGING)
MODE_NO_LOCALIZED_COLLATORS
(/reference/android/content/Context#MODE_NO_LOCALIZED_COLLATORS)
deleteDatabase(String) (/reference/android/content/Context#deleteDatabase([Link]))
openOrCreateDatabase
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 232/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Open a new private SQLiteDatabase associated with this Context's application package.
Create the database file if it doesn't exist.
Parameters
name String : The name (unique in the application package) of the databa
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIV
MODE_WORLD_READABLE
(/reference/android/content/Context#MODE_WORLD_READABLE)
MODE_WORLD_WRITEABLE
(/reference/android/content/Context#MODE_WORLD_WRITEABLE)
MODE_ENABLE_WRITE_AHEAD_LOGGING
(/reference/android/content/Context#MODE_ENABLE_WRITE_AHE
MODE_NO_LOCALIZED_COLLATORS
(/reference/android/content/Context#MODE_NO_LOCALIZED_COL
Returns
[Link] 233/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
See also:
MODE_PRIVATE (/reference/android/content/Context#MODE_PRIVATE)
MODE_ENABLE_WRITE_AHEAD_LOGGING
(/reference/android/content/Context#MODE_ENABLE_WRITE_AHEAD_LOGGING)
MODE_NO_LOCALIZED_COLLATORS
(/reference/android/content/Context#MODE_NO_LOCALIZED_COLLATORS)
deleteDatabase(String) (/reference/android/content/Context#deleteDatabase([Link]))
Returns
Drawable
(/reference/android/graphics/drawable/Drawable)
registerComponentCallbacks
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 234/302
2/15/26, 8:49 PM Context | API reference | Android Developers
After Build.VERSION_CODES.TIRAMISU
(/reference/android/os/Build.VERSION_CODES#TIRAMISU) , registering the ComponentCallbacks
to Activity (/reference/android/app/Activity) context will receive
[Link](Configuration)
(/reference/android/content/ComponentCallbacks#onConfigurationChanged([Link]
iguration))
from [Link](Configuration)
(/reference/android/app/Activity#onConfigurationChanged([Link]))
rather than its base application.
After Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE) , registering the
ComponentCallbacks to InputMethodService
(/reference/android/inputmethodservice/InputMethodService) will receive
[Link](Configuration)
[Link] 235/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/ComponentCallbacks#onConfigurationChanged([Link]
iguration))
from InputmethodService rather than its base application. It is helpful if you want to
handle UI components when the IME has configuration changes.
Parameters
See also:
createWindowContext(int, Bundle)
(/reference/android/content/Context#createWindowContext(int,%[Link]))
registerDeviceIdChangeListener
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Adds a new device ID changed listener to the Context , which will be called when the
device association is changed by the system.
The callback can be called when an app is moved to a different device and the Context is
not explicitly associated with a specific device.
[Link] 236/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
See also:
getDeviceId() (/reference/android/content/Context#getDeviceId())
createDeviceContext(int) (/reference/android/content/Context#createDeviceContext(int))
Register a BroadcastReceiver to be run in the main activity thread. The receiver will be
called with any broadcast Intent that matches filter, in the main application thread.
The system may broadcast Intents that are "sticky" -- these stay around after the
broadcast has finished, to be sent to any later registrations. If your IntentFilter matches
[Link] 237/302
2/15/26, 8:49 PM Context | API reference | Android Developers
one of these sticky Intents, that Intent will be returned by this function and sent to your
receiver as if it had just been broadcast.
There may be multiple sticky Intents that match filter, in which case each of these will be
sent to receiver. In this case, only one of these can be returned directly by the function;
which of these that is returned is arbitrarily decided by the system.
If you know the Intent you are registering for is sticky, you can supply null for your
receiver. In this case, no receiver is registered -- the function simply returns the sticky
Intent that matches filter. In the case of multiple matches, the same rules as described
above apply.
As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE) , the system can place
context-registered broadcasts in a queue while the app is in the
(/develop/background-work/background-tasks/broadcasts#android-14)cached state
(/guide/components/activities/process-lifecycle). When the app leaves the cached state, such
as returning to the foreground, the system delivers any queued broadcasts. Multiple
instances of certain broadcasts might be merged into one broadcast.
As of Build.VERSION_CODES.ICE_CREAM_SANDWICH
(/reference/android/os/Build.VERSION_CODES#ICE_CREAM_SANDWICH) , receivers registered with
this method will correctly respect the [Link](String)
(/reference/android/content/Intent#setPackage([Link])) specified for an Intent being
broadcast. Prior to that, it would be ignored and delivered to all matching registered
receivers. Be careful if using this for security.
[Link] 238/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
Intent The first sticky intent found that matches filter, or null if there are
(/reference/android/content/Intent) none.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
unregisterReceiver(BroadcastReceiver)
(/reference/android/content/Context#unregisterReceiver([Link]))
[Link] 239/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Register to receive intent broadcasts, with the receiver optionally being exposed to
Instant Apps. See registerReceiver([Link],
[Link])
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
for more information. By default Instant Apps cannot interact with receivers in other
applications, this allows you to expose a receiver that Instant Apps can interact with.
As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE) , the system can place
context-registered broadcasts in a queue while the app is in the
(/develop/background-work/background-tasks/broadcasts#android-14)cached state
(/guide/components/activities/process-lifecycle). When the app leaves the cached state, such
as returning to the foreground, the system delivers any queued broadcasts. Multiple
instances of certain broadcasts might be merged into one broadcast.
As of Build.VERSION_CODES.ICE_CREAM_SANDWICH
(/reference/android/os/Build.VERSION_CODES#ICE_CREAM_SANDWICH) , receivers registered with
this method will correctly respect the [Link](String)
(/reference/android/content/Intent#setPackage([Link])) specified for an Intent being
broadcast. Prior to that, it would be ignored and delivered to all matching registered
receivers. Be careful if using this for security.
Parameters
[Link] 240/302
2/15/26, 8:49 PM Context | API reference | Android Developers
flags int : Additional options for the receiver. For apps targeting
Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) or
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED) mu
specified if the receiver isn't being registered for system broadcasts
(/guide/components/broadcasts#system-broadcasts) or a
SecurityException (/reference/java/lang/SecurityException) will b
If RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) is speci
receiver may additionally specify RECEIVER_VISIBLE_TO_INSTANT
(/reference/android/content/Context#RECEIVER_VISIBLE_TO_INSTANT
For a complete list of system broadcast actions, see the
BROADCAST_ACTIONS.TXT file in the Android SDK. If both
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) and
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED) are
specified, an IllegalArgumentException
(/reference/java/lang/IllegalArgumentException) will be thrown.
Value is either 0 or a combination of the following:
RECEIVER_VISIBLE_TO_INSTANT_APPS
(/reference/android/content/Context#RECEIVER_VISIBLE_TO_INSTA
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED)
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED)
Returns
Intent The first sticky intent found that matches filter, or null if there are
(/reference/android/content/Intent) none.
See also:
[Link] 241/302
2/15/26, 8:49 PM Context | API reference | Android Developers
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
unregisterReceiver(BroadcastReceiver)
(/reference/android/content/Context#unregisterReceiver([Link]))
As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE) , the system can place
context-registered broadcasts in a queue while the app is in the
(/develop/background-work/background-tasks/broadcasts#android-14)cached state
(/guide/components/activities/process-lifecycle). When the app leaves the cached state, such
as returning to the foreground, the system delivers any queued broadcasts. Multiple
instances of certain broadcasts might be merged into one broadcast.
[Link] 242/302
2/15/26, 8:49 PM Context | API reference | Android Developers
As of Build.VERSION_CODES.ICE_CREAM_SANDWICH
(/reference/android/os/Build.VERSION_CODES#ICE_CREAM_SANDWICH) , receivers registered with
this method will correctly respect the [Link](String)
(/reference/android/content/Intent#setPackage([Link])) specified for an Intent being
broadcast. Prior to that, it would be ignored and delivered to all matching registered
receivers. Be careful if using this for security.
Parameters
scheduler Handler : Handler identifying the thread that will receive the Intent. If
main thread of the process will be used.
flags int : Additional options for the receiver. For apps targeting
Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) or
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED) mu
specified if the receiver isn't being registered for system broadcasts
(/guide/components/broadcasts#system-broadcasts) or a
SecurityException (/reference/java/lang/SecurityException) will b
If RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) is speci
receiver may additionally specify RECEIVER_VISIBLE_TO_INSTANT
(/reference/android/content/Context#RECEIVER_VISIBLE_TO_INSTANT
For a complete list of system broadcast actions, see the
BROADCAST_ACTIONS.TXT file in the Android SDK. If both
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED) and
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED) are
specified, an IllegalArgumentException
[Link] 243/302
2/15/26, 8:49 PM Context | API reference | Android Developers
RECEIVER_VISIBLE_TO_INSTANT_APPS
(/reference/android/content/Context#RECEIVER_VISIBLE_TO_INSTA
RECEIVER_EXPORTED
(/reference/android/content/Context#RECEIVER_EXPORTED)
RECEIVER_NOT_EXPORTED
(/reference/android/content/Context#RECEIVER_NOT_EXPORTED)
Returns
Intent The first sticky intent found that matches filter, or null if there are
(/reference/android/content/Intent) none.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
unregisterReceiver(BroadcastReceiver)
(/reference/android/content/Context#unregisterReceiver([Link]))
[Link] 244/302
2/15/26, 8:49 PM Context | API reference | Android Developers
As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE
(/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE) , the system can place
context-registered broadcasts in a queue while the app is in the
(/develop/background-work/background-tasks/broadcasts#android-14)cached state
(/guide/components/activities/process-lifecycle). When the app leaves the cached state, such
as returning to the foreground, the system delivers any queued broadcasts. Multiple
instances of certain broadcasts might be merged into one broadcast.
As of Build.VERSION_CODES.ICE_CREAM_SANDWICH
(/reference/android/os/Build.VERSION_CODES#ICE_CREAM_SANDWICH) , receivers registered with
this method will correctly respect the [Link](String)
(/reference/android/content/Intent#setPackage([Link])) specified for an Intent being
broadcast. Prior to that, it would be ignored and delivered to all matching registered
receivers. Be careful if using this for security.
[Link] 245/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link],%[Link],%[Link],%20int))
to register a receiver with flags.
Parameters
scheduler Handler : Handler identifying the thread that will receive the Intent.
If null, the main thread of the process will be used.
Returns
Intent The first sticky intent found that matches filter, or null if there are
(/reference/android/content/Intent) none.
See also:
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
unregisterReceiver(BroadcastReceiver)
(/reference/android/content/Context#unregisterReceiver([Link]))
[Link] 246/302
2/15/26, 8:49 PM Context | API reference | Android Developers
removeStickyBroadcast
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Parameters
See also:
sendStickyBroadcast(Intent)
(/reference/android/content/Context#sendStickyBroadcast([Link]))
removeStickyBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 247/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Version of removeStickyBroadcast([Link])
(/reference/android/content/Context#removeStickyBroadcast([Link])) that allows
you to specify the user the broadcast will be sent to. This is not available to applications
that are not pre-installed on the system image.
Parameters
See also:
sendStickyBroadcastAsUser(Intent, UserHandle)
(/reference/android/content/Context#sendStickyBroadcastAsUser([Link],%20android.
[Link]))
revokeSelfPermissionOnKill
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 248/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Throws
See also:
revokeSelfPermissionsOnKill(Collection)
(/reference/android/content/Context#revokeSelfPermissionsOnKill([Link]<[Link]>
))
revokeSelfPermissionsOnKill
Added in API level 33 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Triggers the revocation of one or more permissions for the calling package. A package is
only able to revoke runtime permissions. If a permission is not currently granted, it is
ignored and will not get revoked (even if later granted by the user). Ultimately, you should
[Link] 249/302
2/15/26, 8:49 PM Context | API reference | Android Developers
never make assumptions about a permission status as users may grant or revoke them at
any time.
The revocation happens asynchronously and kills all processes running in the calling UID.
It will be triggered once it is safe to do so. In particular, it will not be triggered as long as
the package remains in the foreground, or has any active manifest components (e.g.
when another app is accessing a content provider in the package).
If you want to revoke the permissions right away, you could call [Link]() in
[Link] with a delay to allow completion of async IPC, But [Link]()
could affect other apps that are accessing your app at the moment. For example, apps
accessing a content provider in your app will all crash.
Note that the settings UI shows a permission group as granted as long as at least one
permission in the group is granted. If you want the user to observe the revocation in the
settings, you should revoke every permission in the target group. To learn the current list
of permissions in a group, you may use
[Link](String, Executor, Consumer)
(/reference/android/content/pm/PackageManager#getGroupOfPlatformPermission([Link],%2
[Link],%[Link]<[Link]>))
and [Link](String, Executor,
Consumer)
(/reference/android/content/pm/PackageManager#getPlatformPermissionsForGroup([Link],
%[Link],%[Link]<[Link]<[Link]>>))
. This list of permissions may evolve over time, so it is recommended to check whether it
contains any permission you wish to retain before trying to revoke an entire group.
Parameters
Throws
[Link] 250/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
Remove all permissions to access a particular content provider Uri that were previously
added with grantUriPermission(String, Uri, int)
(/reference/android/content/Context#grantUriPermission([Link],%[Link],%20int))
or any other mechanism. The given Uri will match all previously granted Uris that are the
same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke
both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will
not remove any prefix grants that exist at a higher level.
Prior to Build.VERSION_CODES.LOLLIPOP
(/reference/android/os/Build.VERSION_CODES#LOLLIPOP) , if you did not have regular
permission access to a Uri, but had received access to it through a specific Uri permission
grant, you could not revoke that grant with this function and a SecurityException
(/reference/java/lang/SecurityException) would be thrown. As of
Build.VERSION_CODES.LOLLIPOP (/reference/android/os/Build.VERSION_CODES#LOLLIPOP) , this
function will not throw a security exception, but will remove whatever permission grants to
the Uri had been given to the app (or none).
[Link] 251/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
uri Uri : The Uri you would like to revoke access to.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
See also:
[Link] 252/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Remove permissions to access a particular content provider Uri that were previously
added with grantUriPermission(String, Uri, int)
(/reference/android/content/Context#grantUriPermission([Link],%[Link],%20int))
for a specific target package. The given Uri will match all previously granted Uris that are
the same or a sub-path of the given Uri. That is, revoking "content://foo/target" will revoke
both "content://foo/target" and "content://foo/target/sub", but not "content://foo". It will
not remove any prefix grants that exist at a higher level.
Parameters
toPackage String : The package you had previously granted access to.
uri Uri : The Uri you would like to revoke access to.
Intent.FLAG_GRANT_READ_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_READ_URI_PERM
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
(/reference/android/content/Intent#FLAG_GRANT_WRITE_URI_PER
See also:
[Link] 253/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
See also:
[Link] 254/302
2/15/26, 8:49 PM Context | API reference | Android Developers
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
Parameters
[Link] 255/302
2/15/26, 8:49 PM Context | API reference | Android Developers
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
See also:
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
Broadcast the given intent to all interested BroadcastReceivers. This call is asynchronous;
it returns immediately, and you will continue executing while the receivers are run. No
results are propagated from receivers and receivers can not abort the broadcast. If you
want to allow receivers to propagate results or abort the broadcast, you must send an
ordered broadcast using sendOrderedBroadcast([Link],
[Link] 256/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link])
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
.
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
See also:
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent, String)
(/reference/android/content/Context#sendBroadcast([Link],%[Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
sendBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 257/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Version of sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) that allows you to
specify the user the broadcast will be sent to. This is not available to applications that are
not pre-installed on the system image.
Requires [Link].INTERACT_ACROSS_USERS
Parameters
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 258/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
See also:
sendBroadcast(Intent, String)
(/reference/android/content/Context#sendBroadcast([Link],%[Link]))
sendBroadcastWithMultiplePermissions
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 259/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
See also:
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
sendOrderedBroadcast
Added in API level 30 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 260/302
2/15/26, 8:49 PM Context | API reference | Android Developers
int initialCode,
String (/reference/java/lang/String) initialData,
Bundle (/reference/android/os/Bundle) initialExtras)
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
[Link] 261/302
2/15/26, 8:49 PM Context | API reference | Android Developers
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
sendOrderedBroadcast
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Version of sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) that allows you to
receive data back from the broadcast. This is accomplished by supplying your own
BroadcastReceiver when calling, which will be treated as a final receiver at the end of the
broadcast -- its [Link]
(/reference/android/content/BroadcastReceiver#onReceive([Link],%[Link]
[Link]))
method will be called with the result values collected from the other receivers. The
broadcast will be serialized in the same way as calling
sendOrderedBroadcast([Link], [Link])
[Link] 262/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
.
Like sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) , this method is
asynchronous; it will return before [Link]() is called.
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
[Link] 263/302
2/15/26, 8:49 PM Context | API reference | Android Developers
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendBroadcast(Intent, String)
(/reference/android/content/Context#sendBroadcast([Link],%[Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
Activity.RESULT_OK (/reference/android/app/Activity#RESULT_OK)
sendOrderedBroadcast
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Broadcast the given intent to all interested BroadcastReceivers, delivering them one at a
time to allow more preferred receivers to consume the broadcast before it is delivered to
less preferred receivers. This call is asynchronous; it returns immediately, and you will
continue executing while the receivers are run.
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
[Link] 264/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendOrderedBroadcast
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 265/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Version of sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) that allows you to
receive data back from the broadcast. This is accomplished by supplying your own
BroadcastReceiver when calling, which will be treated as a final receiver at the end of the
broadcast -- its [Link]
(/reference/android/content/BroadcastReceiver#onReceive([Link],%[Link]
[Link]))
method will be called with the result values collected from the other receivers. The
broadcast will be serialized in the same way as calling
sendOrderedBroadcast([Link], [Link])
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
.
Like sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) , this method is
asynchronous; it will return before [Link]() is called.
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
This value cannot be null .
[Link] 266/302
2/15/26, 8:49 PM Context | API reference | Android Developers
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendBroadcast(Intent, String)
(/reference/android/content/Context#sendBroadcast([Link],%[Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
Activity.RESULT_OK (/reference/android/app/Activity#RESULT_OK)
sendOrderedBroadcast
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 267/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Broadcast the given intent to all interested BroadcastReceivers, delivering them one at a
time to allow more preferred receivers to consume the broadcast before it is delivered to
less preferred receivers. This call is asynchronous; it returns immediately, and you will
continue executing while the receivers are run.
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
See also:
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendOrderedBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 268/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
[Link] 269/302
2/15/26, 8:49 PM Context | API reference | Android Developers
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
sendStickyBroadcast
Added in API level 1 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Perform a sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) that is "sticky,"
meaning the Intent you are sending stays around after the broadcast is complete, so that
[Link] 270/302
2/15/26, 8:49 PM Context | API reference | Android Developers
others can quickly retrieve that data through the return value of
registerReceiver([Link],
[Link])
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
. In all other ways, this behaves the same as sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) .
Requires [Link].BROADCAST_STICKY
(/reference/android/[Link]#BROADCAST_STICKY)
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast, and the Intent will be held to be re-
broadcast to future receivers.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendStickyBroadcast
Added in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 31 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 271/302
2/15/26, 8:49 PM Context | API reference | Android Developers
non-sticky broadcast to report that something has changed, with another mechanism for apps to
retrieve the current value whenever desired.
Perform a sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) that is "sticky,"
meaning the Intent you are sending stays around after the broadcast is complete, so that
others can quickly retrieve that data through the return value of
registerReceiver([Link],
[Link])
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
. In all other ways, this behaves the same as sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) .
Requires [Link].BROADCAST_STICKY
(/reference/android/[Link]#BROADCAST_STICKY)
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast, and the Intent will be held to be re-
broadcast to future receivers.
This value cannot be null .
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
[Link] 272/302
2/15/26, 8:49 PM Context | API reference | Android Developers
sendStickyBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Version of sendStickyBroadcast([Link])
(/reference/android/content/Context#sendStickyBroadcast([Link])) that allows you
to specify the user the broadcast will be sent to. This is not available to applications that
are not pre-installed on the system image.
Requires [Link].INTERACT_ACROSS_USERS and
[Link].BROADCAST_STICKY
(/reference/android/[Link]#BROADCAST_STICKY)
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast, and the Intent will be held to be re-
broadcast to future receivers.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
[Link] 273/302
2/15/26, 8:49 PM Context | API reference | Android Developers
sendStickyOrderedBroadcast
Added in API level 5 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Version of sendStickyBroadcast(Intent)
(/reference/android/content/Context#sendStickyBroadcast([Link])) that allows you
to receive data back from the broadcast. This is accomplished by supplying your own
BroadcastReceiver when calling, which will be treated as a final receiver at the end of the
broadcast -- its [Link]
(/reference/android/content/BroadcastReceiver#onReceive([Link],%[Link]
[Link]))
method will be called with the result values collected from the other receivers. The
broadcast will be serialized in the same way as calling
sendOrderedBroadcast([Link], [Link])
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
.
Like sendBroadcast([Link])
(/reference/android/content/Context#sendBroadcast([Link])) , this method is
asynchronous; it will return before [Link]() is called. Note that the
sticky data stored is only the data you initially supply to the broadcast, not the result of
any changes made by the receivers.
[Link] 274/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Requires [Link].BROADCAST_STICKY
(/reference/android/[Link]#BROADCAST_STICKY)
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
sendBroadcast(Intent)
(/reference/android/content/Context#sendBroadcast([Link]))
sendBroadcast(Intent, String)
(/reference/android/content/Context#sendBroadcast([Link],%[Link]))
sendOrderedBroadcast(Intent, String)
(/reference/android/content/Context#sendOrderedBroadcast([Link],%[Link]
ng))
sendStickyBroadcast(Intent)
(/reference/android/content/Context#sendStickyBroadcast([Link]))
BroadcastReceiver (/reference/android/content/BroadcastReceiver)
[Link] 275/302
2/15/26, 8:49 PM Context | API reference | Android Developers
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
Activity.RESULT_OK (/reference/android/app/Activity#RESULT_OK)
sendStickyOrderedBroadcastAsUser
Added in API level 17 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Deprecated in API level 21 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Version of sendStickyOrderedBroadcast([Link],
[Link], [Link], int,
[Link], [Link])
(/reference/android/content/Context#sendStickyOrderedBroadcast([Link],%20androi
[Link],%[Link],%20int,%[Link],%[Link]
e))
that allows you to specify the user the broadcast will be sent to. This is not available to
applications that are not pre-installed on the system image.
[Link] 276/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
intent Intent : The Intent to broadcast; all receivers matching this Intent
will receive the broadcast.
initialCode int : An initial value for the result code. Often Activity.RESULT_OK.
initialData String : An initial value for the result data. Often null.
initialExtras Bundle : An initial value for the result extras. Often null.
See also:
[Link] 277/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Set the base theme for this context. Note that this should be called before any views are
instantiated in the Context (for example before calling [Link](View)
(/reference/android/app/Activity#setContentView([Link])) or
[Link](int, ViewGroup)
(/reference/android/view/LayoutInflater#inflate(int,%[Link])) ).
Parameters
Parameters
bitmap Bitmap
[Link] 278/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Throws
IOException
(/reference/java/io/IOException)
Parameters
data InputStream
Throws
IOException
(/reference/java/io/IOException)
[Link] 279/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
options Bundle : Additional options for how the Activity should be started. Se
startActivity(Intent, Bundle)
(/reference/android/content/Context#startActivity([Link]
[Link](Intent, Bundle)} for more details.
Throws
ActivityNotFoundException
(/reference/android/content/ActivityNotFoundException)
See also:
[Link] 280/302
2/15/26, 8:49 PM Context | API reference | Android Developers
startActivities(Intent[])
(/reference/android/content/Context#startActivities([Link][]))
[Link](Intent, ResolveInfoFlags)
(/reference/android/content/pm/PackageManager#resolveActivity([Link],%20android.
[Link]))
Parameters
Throws
ActivityNotFoundException
(/reference/android/content/ActivityNotFoundException)
See also:
startActivities(Intent[], Bundle)
(/reference/android/content/Context#startActivities([Link][],%[Link]))
[Link](Intent, ResolveInfoFlags)
(/reference/android/content/pm/PackageManager#resolveActivity([Link],%20android.
[Link]))
[Link] 281/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Throws
ActivityNotFoundException `
(/reference/android/content/ActivityNotFoundException)
See also:
startActivity(Intent, Bundle)
(/reference/android/content/Context#startActivity([Link],%[Link]))
[Link](Intent, ResolveInfoFlags)
(/reference/android/content/pm/PackageManager#resolveActivity([Link],%20android.
[Link]))
[Link] 282/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Launch a new activity. You will not receive any information about when the activity exits.
Parameters
options Bundle : Additional options for how the Activity should be started.
May be null if there are no options. See ActivityOptions
(/reference/android/app/ActivityOptions) for how to build the Bundle
supplied here; there are no supported definitions for building it
manually.
Throws
ActivityNotFoundException
(/reference/android/content/ActivityNotFoundException)
See also:
startActivity(Intent)
(/reference/android/content/Context#startActivity([Link]))
[Link](Intent, ResolveInfoFlags)
(/reference/android/content/pm/PackageManager#resolveActivity([Link],%20android.
[Link]))
[Link] 283/302
2/15/26, 8:49 PM Context | API reference | Android Developers
startForegroundService
Added in API level 26 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Similar to startService([Link])
(/reference/android/content/Context#startService([Link])) , but with an implicit
promise that the Service will call startForeground(int, [Link])
(/reference/android/app/Service#startForeground(int,%[Link])) once it begins
running. The service is given an amount of time comparable to the ANR interval to do this,
otherwise the system will automatically crash the process, in which case an internal
exception ForegroundServiceDidNotStartInTimeException is logged on logcat on
devices running SDK Version Build.VERSION_CODES.S
(/reference/android/os/Build.VERSION_CODES#S) or later. On older Android versions, an internal
exception RemoteServiceException is logged instead, with a corresponding message.
Parameters
service Intent : Identifies the service to be started. The Intent must be fully
explicit (supplying a component name). Additional values may be
included in the Intent extras to supply arguments along with this
specific start call.
[Link] 284/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Returns
Throws
See also:
stopService(Intent) (/reference/android/content/Context#stopService([Link]))
[Link](int, [Link])
(/reference/android/app/Service#startForeground(int,%[Link]))
[Link] 285/302
2/15/26, 8:49 PM Context | API reference | Android Developers
This function is not synchronous -- it returns as soon as the instrumentation has started
and while it is running.
Instrumentation is normally only allowed to run against a package that is either unsigned
or signed with a signature that the the instrumentation package is also signed with
(ensuring the target trusts the instrumentation).
Parameters
Returns
[Link] 286/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Same as startIntentSender([Link],
[Link], int, int, int, [Link])
(/reference/android/content/Context#startIntentSender([Link],%[Link]
[Link],%20int,%20int,%20int,%[Link]))
with no options specified.
Parameters
flagsMask int : Intent flags in the original IntentSender that you would like to ch
Value is either 0 or a combination of the following:
Intent.FLAG_FROM_BACKGROUND (/reference/android/content/In
Intent.FLAG_DEBUG_LOG_RESOLUTION (/reference/android/con
Intent.FLAG_EXCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_INCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_ACTIVITY_MATCH_EXTERNAL (/reference/android
Intent.FLAG_ACTIVITY_NO_HISTORY (/reference/android/cont
Intent.FLAG_ACTIVITY_SINGLE_TOP (/reference/android/cont
Intent.FLAG_ACTIVITY_NEW_TASK (/reference/android/conten
Intent.FLAG_ACTIVITY_MULTIPLE_TASK (/reference/android/c
Intent.FLAG_ACTIVITY_CLEAR_TOP (/reference/android/conte
Intent.FLAG_ACTIVITY_FORWARD_RESULT (/reference/android
[Link] 287/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP (/reference/andro
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS (/reference
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (/reference
Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY (/referenc
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NEW_DOCUMENT (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NO_USER_ACTION (/reference/android
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_NO_ANIMATION (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_TASK (/reference/android/cont
Intent.FLAG_ACTIVITY_TASK_ON_HOME (/reference/android/co
Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS (/reference/and
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT (/reference/andro
Intent.FLAG_RECEIVER_REGISTERED_ONLY (/reference/andro
Intent.FLAG_RECEIVER_REPLACE_PENDING (/reference/andro
Intent.FLAG_RECEIVER_FOREGROUND (/reference/android/cont
Intent.FLAG_RECEIVER_NO_ABORT (/reference/android/conten
Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS (/refere
Intent.FLAG_FROM_BACKGROUND (/reference/android/content/In
Intent.FLAG_DEBUG_LOG_RESOLUTION (/reference/android/con
Intent.FLAG_EXCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_INCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_ACTIVITY_MATCH_EXTERNAL (/reference/android
Intent.FLAG_ACTIVITY_NO_HISTORY (/reference/android/cont
Intent.FLAG_ACTIVITY_SINGLE_TOP (/reference/android/cont
Intent.FLAG_ACTIVITY_NEW_TASK (/reference/android/conten
[Link] 288/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_ACTIVITY_MULTIPLE_TASK (/reference/android/c
Intent.FLAG_ACTIVITY_CLEAR_TOP (/reference/android/conte
Intent.FLAG_ACTIVITY_FORWARD_RESULT (/reference/android
Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP (/reference/andro
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS (/reference
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (/reference
Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY (/referenc
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NEW_DOCUMENT (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NO_USER_ACTION (/reference/android
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_NO_ANIMATION (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_TASK (/reference/android/cont
Intent.FLAG_ACTIVITY_TASK_ON_HOME (/reference/android/co
Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS (/reference/and
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT (/reference/andro
Intent.FLAG_RECEIVER_REGISTERED_ONLY (/reference/andro
Intent.FLAG_RECEIVER_REPLACE_PENDING (/reference/andro
Intent.FLAG_RECEIVER_FOREGROUND (/reference/android/cont
Intent.FLAG_RECEIVER_NO_ABORT (/reference/android/conten
Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS (/refere
Throws
[Link] 289/302
2/15/26, 8:49 PM Context | API reference | Android Developers
[Link]
(/reference/android/content/[Link])
See also:
startActivity(Intent)
(/reference/android/content/Context#startActivity([Link]))
Parameters
[Link] 290/302
2/15/26, 8:49 PM Context | API reference | Android Developers
flagsMask int : Intent flags in the original IntentSender that you would like to ch
Value is either 0 or a combination of the following:
Intent.FLAG_FROM_BACKGROUND (/reference/android/content/In
Intent.FLAG_DEBUG_LOG_RESOLUTION (/reference/android/con
Intent.FLAG_EXCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_INCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_ACTIVITY_MATCH_EXTERNAL (/reference/android
Intent.FLAG_ACTIVITY_NO_HISTORY (/reference/android/cont
Intent.FLAG_ACTIVITY_SINGLE_TOP (/reference/android/cont
Intent.FLAG_ACTIVITY_NEW_TASK (/reference/android/conten
Intent.FLAG_ACTIVITY_MULTIPLE_TASK (/reference/android/c
Intent.FLAG_ACTIVITY_CLEAR_TOP (/reference/android/conte
Intent.FLAG_ACTIVITY_FORWARD_RESULT (/reference/android
Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP (/reference/andro
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS (/reference
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (/reference
Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY (/referenc
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NEW_DOCUMENT (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NO_USER_ACTION (/reference/android
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_NO_ANIMATION (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_TASK (/reference/android/cont
[Link] 291/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_ACTIVITY_TASK_ON_HOME (/reference/android/co
Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS (/reference/and
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT (/reference/andro
Intent.FLAG_RECEIVER_REGISTERED_ONLY (/reference/andro
Intent.FLAG_RECEIVER_REPLACE_PENDING (/reference/andro
Intent.FLAG_RECEIVER_FOREGROUND (/reference/android/cont
Intent.FLAG_RECEIVER_NO_ABORT (/reference/android/conten
Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS (/refere
Intent.FLAG_FROM_BACKGROUND (/reference/android/content/In
Intent.FLAG_DEBUG_LOG_RESOLUTION (/reference/android/con
Intent.FLAG_EXCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_INCLUDE_STOPPED_PACKAGES (/reference/andro
Intent.FLAG_ACTIVITY_MATCH_EXTERNAL (/reference/android
Intent.FLAG_ACTIVITY_NO_HISTORY (/reference/android/cont
Intent.FLAG_ACTIVITY_SINGLE_TOP (/reference/android/cont
Intent.FLAG_ACTIVITY_NEW_TASK (/reference/android/conten
Intent.FLAG_ACTIVITY_MULTIPLE_TASK (/reference/android/c
Intent.FLAG_ACTIVITY_CLEAR_TOP (/reference/android/conte
Intent.FLAG_ACTIVITY_FORWARD_RESULT (/reference/android
Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP (/reference/andro
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS (/reference
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (/reference
Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY (/referenc
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NEW_DOCUMENT (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET (/referenc
Intent.FLAG_ACTIVITY_NO_USER_ACTION (/reference/android
[Link] 292/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT (/reference/andr
Intent.FLAG_ACTIVITY_NO_ANIMATION (/reference/android/co
Intent.FLAG_ACTIVITY_CLEAR_TASK (/reference/android/cont
Intent.FLAG_ACTIVITY_TASK_ON_HOME (/reference/android/co
Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS (/reference/and
Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT (/reference/andro
Intent.FLAG_RECEIVER_REGISTERED_ONLY (/reference/andro
Intent.FLAG_RECEIVER_REPLACE_PENDING (/reference/andro
Intent.FLAG_RECEIVER_FOREGROUND (/reference/android/cont
Intent.FLAG_RECEIVER_NO_ABORT (/reference/android/conten
Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS (/refere
options Bundle : Additional options for how the Activity should be started. Se
(/reference/android/content/Context#startActivity([Link]
supplied by the IntentSender, options given here will override any that
This value may be null .
Throws
[Link]
(/reference/android/content/[Link])
See also:
startActivity(Intent, Bundle)
(/reference/android/content/Context#startActivity([Link],%[Link]))
[Link] 293/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Request that a given application service be started. The Intent should either contain the
complete class name of a specific service implementation to start, or a specific package
name to target. If the Intent is less specified, it logs a warning about this. In this case any
of the multiple matching services may be used. If this service is not already running, it will
be instantiated and started (creating a process for it if needed); if it is running then it
remains running.
Every call to this method will result in a corresponding call to the target service's
[Link](Intent, int, int)
(/reference/android/app/Service#onStartCommand([Link],%20int,%20int)) method,
with the intent given here. This provides a convenient way to submit jobs to a service
without having to bind and call on to its interface.
The system attempts to keep running services around as much as possible. The only time
they should be stopped is if the current foreground application is using so many
resources that the service needs to be killed. If any errors happen in the service's
process, it will automatically be restarted.
Note: Each call to startService() results in significant work done by the system to manage service
lifecycle surrounding the processing of the intent, which can take multiple milliseconds of CPU time.
Due to this cost, startService() should not be used for frequent intent delivery to a service, and only for
[Link] 294/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
service Intent : Identifies the service to be started. The Intent must be fully
explicit (supplying a component name). Additional values may be
included in the Intent extras to supply arguments along with this
specific start call.
Returns
Throws
[Link] 295/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
startForegroundService(Intent)
(/reference/android/content/Context#startForegroundService([Link]))
stopService(Intent) (/reference/android/content/Context#stopService([Link]))
Request that a given application service be stopped. If the service is not running, nothing
happens. Otherwise it is stopped. Note that calls to startService() are not counted -- this
stops the service no matter how many times it was started.
[Link] 296/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Parameters
Returns
boolean If there is a service matching the given Intent that is already running,
then it is stopped and true is returned; else false is returned.
Throws
[Link] 297/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
startService(Intent) (/reference/android/content/Context#startService([Link]))
Disconnect from an application service. You will no longer receive calls as the service is
restarted, and the service is now allowed to stop at any time.
Parameters
See also:
unregisterComponentCallbacks
Added in API level 14 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 298/302
2/15/26, 8:49 PM Context | API reference | Android Developers
(/reference/android/content/Context#registerComponentCallbacks([Link]
cks))
.
Parameters
callback ComponentCallbacks
unregisterDeviceIdChangeListener
Added in API level 34 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
Removes a device ID changed listener from the Context. It's a no-op if the listener is not
already registered.
Parameters
See also:
getDeviceId() (/reference/android/content/Context#getDeviceId())
registerDeviceIdChangeListener(Executor, IntConsumer)
(/reference/android/content/Context#registerDeviceIdChangeListener([Link],%
[Link]))
[Link] 299/302
2/15/26, 8:49 PM Context | API reference | Android Developers
Unregister a previously registered BroadcastReceiver. All filters that have been registered
for this BroadcastReceiver will be removed.
Parameters
Throws
See also:
registerReceiver(BroadcastReceiver, IntentFilter)
(/reference/android/content/Context#registerReceiver([Link],%20androi
[Link]))
updateServiceGroup
Added in API level 29 (/guide/topics/manifest/uses-sdk-element#ApiLevels)
[Link] 300/302
2/15/26, 8:49 PM Context | API reference | Android Developers
or a related method, change how the system manages that service's process in relation to
other processes. This doesn't modify the original bind flags that were passed in when
binding, but adjusts how the process will be managed in some cases based on those
flags. Currently only works on isolated processes (will be ignored for non-isolated
processes).
Note that this call does not take immediate effect, but will be applied the next time the
impacted process is adjusted for some other reason. Typically you would call this before
then calling a new bindIsolatedService(Intent, BindServiceFlags, String,
Executor, ServiceConnection)
(/reference/android/content/Context#bindIsolatedService([Link],%[Link].
[Link],%[Link],%[Link],%[Link].S
erviceConnection))
on the service of interest, with that binding causing the process to be shuffled
accordingly.
Parameters
group int : A group to put this connection's process in. Upon calling here,
this will override any previous group that was set for that process.
The group tells the system about processes that are logically
grouped together, so should be managed as one unit of importance
(such as when being considered a recently used app). All processes
in the same app with the same group are considered to be related.
Supplying 0 reverts to the default behavior of not grouping.
[Link] 301/302
2/15/26, 8:49 PM Context | API reference | Android Developers
See also:
Content and code samples on this page are subject to the licenses described in the Content License
(/license). Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
[Link] 302/302