void
|
attachBaseContext(Context base)
Set the base context for this ContextWrapper.
|
boolean
|
bindIsolatedService(Intent service, int flags, String instanceName, Executor executor, ServiceConnection conn)
Variation of bindService(Intent, BindServiceFlags, Executor, ServiceConnection) that, in the specific case of isolated
services, allows the caller to generate multiple instances of a service
from a single component declaration.
|
boolean
|
bindService(Intent service, int flags, Executor executor, ServiceConnection conn)
Same as bindService(Intent, ServiceConnection, int) with executor to control ServiceConnection
callbacks.
|
boolean
|
bindService(Intent service, ServiceConnection conn, Context.BindServiceFlags flags)
See bindService(android.content.Intent, android.content.ServiceConnection, int)
Call BindServiceFlags.of(long) to obtain a BindServiceFlags object.
|
boolean
|
bindService(Intent service, ServiceConnection conn, int flags)
Connects to an application service, creating it if needed.
|
boolean
|
bindService(Intent service, Context.BindServiceFlags flags, Executor executor, ServiceConnection conn)
See bindService(android.content.Intent, int, java.util.concurrent.Executor, android.content.ServiceConnection)
Call BindServiceFlags.of(long) to obtain a BindServiceFlags object.
|
int
|
checkCallingOrSelfPermission(String permission)
Determine whether the calling process of an IPC or you have been
granted a particular permission.
|
int
|
checkCallingOrSelfUriPermission(Uri uri, int modeFlags)
Determine whether the calling process of an IPC or you has been granted
permission to access a specific URI.
|
int[]
|
,%20int)">checkCallingOrSelfUriPermissions(List<Uri> uris, int modeFlags)
Determine whether the calling process of an IPC or you has been granted
permission to access a list of URIs.
|
int
|
checkCallingPermission(String permission)
Determine whether the calling process of an IPC you are handling has been
granted a particular permission.
|
int
|
checkCallingUriPermission(Uri uri, int modeFlags)
Determine whether the calling process and uid has been
granted permission to access a specific URI.
|
int[]
|
,%20int)">checkCallingUriPermissions(List<Uri> uris, int modeFlags)
Determine whether the calling process and uid has been
granted permission to access a list of URIs.
|
int
|
checkContentUriPermissionFull(Uri uri, int pid, int uid, int modeFlags)
Determine whether a particular process and uid has been granted
permission to access a specific content URI.
|
int
|
checkPermission(String permission, int pid, int uid)
Determine whether the given permission is allowed for a particular
process and user ID running in the system.
|
int
|
checkSelfPermission(String permission)
Determine whether you have been granted a particular permission.
|
int
|
checkUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags)
Check both a Uri and normal permission.
|
int
|
checkUriPermission(Uri uri, int pid, int uid, int modeFlags)
Determine whether a particular process and uid has been granted
permission to access a specific URI.
|
int[]
|
,%20int,%20int,%20int)">checkUriPermissions(List<Uri> uris, int pid, int uid, int modeFlags)
Determine whether a particular process and uid has been granted
permission to access a list of URIs.
|
void
|
clearWallpaper()
This method is deprecated.
Use WallpaperManager.clear() instead.
This method requires the caller to hold the permission
Manifest.permission.SET_WALLPAPER .
|
Context
|
createAttributionContext(String attributionTag)
Return a new Context object for the current Context but attribute to a different tag.
|
Context
|
createConfigurationContext(Configuration overrideConfiguration)
Return a new Context object for the current Context but whose resources
are adjusted to match the given Configuration.
|
Context
|
createContext(ContextParams contextParams)
Creates a context with specific properties and behaviors.
|
Context
|
createDeviceContext(int deviceId)
Returns a new Context object from the current context but with device association
given by the deviceId .
|
Context
|
createDeviceProtectedStorageContext()
Return a new Context object for the current Context but whose storage
APIs are backed by device-protected storage.
|
Context
|
createDisplayContext(Display display)
Returns a new Context object from the current context but with resources
adjusted to match the metrics of display .
|
Context
|
createPackageContext(String packageName, int flags)
Return a new Context object for the given application name.
|
Context
|
createWindowContext(int type, Bundle options)
Creates a Context for a non-activity window.
|
Context
|
createWindowContext(Display display, int type, Bundle options)
Creates a Context for a non-activity window on the given
Display .
|
String[]
|
databaseList()
Returns an array of strings naming the private databases associated with
this Context's application package.
|
boolean
|
deleteDatabase(String name)
Delete an existing private SQLiteDatabase associated with this Context's
application package.
|
boolean
|
deleteFile(String name)
Delete the given private file associated with this Context's
application package.
|
boolean
|
deleteSharedPreferences(String name)
Delete an existing shared preferences file.
|
void
|
enforceCallingOrSelfPermission(String permission, String message)
If neither you nor the calling process of an IPC you are
handling has been granted a particular permission, throw a
SecurityException .
|
void
|
enforceCallingOrSelfUriPermission(Uri uri, int modeFlags, String message)
If the calling process of an IPC or you has not been
granted permission to access a specific URI, throw SecurityException .
|
void
|
enforceCallingPermission(String permission, String message)
If the calling process of an IPC you are handling has not been
granted a particular permission, throw a SecurityException .
|
void
|
enforceCallingUriPermission(Uri uri, int modeFlags, String message)
If the calling process and uid has not been granted
permission to access a specific URI, throw SecurityException .
|
void
|
enforcePermission(String permission, int pid, int uid, String message)
If the given permission is not allowed for a particular process
and user ID running in the system, throw a SecurityException .
|
void
|
enforceUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags, String message)
Enforce both a Uri and normal permission.
|
void
|
enforceUriPermission(Uri uri, int pid, int uid, int modeFlags, String message)
If a particular process and uid has not been granted
permission to access a specific URI, throw SecurityException .
|
String[]
|
fileList()
Returns an array of strings naming the private files associated with
this Context's application package.
|
Context
|
getApplicationContext()
Return the context of the single, global Application object of the
current process.
|
ApplicationInfo
|
getApplicationInfo()
Return the full application info for this context's package.
|
AssetManager
|
getAssets()
Returns an AssetManager instance for the application's package.
|
AttributionSource
|
getAttributionSource()
|
Context
|
getBaseContext()
|
File
|
getCacheDir()
Returns the absolute path to the application specific cache directory on
the filesystem.
|
ClassLoader
|
getClassLoader()
Return a class loader you can use to retrieve classes in this package.
|
File
|
getCodeCacheDir()
Returns the absolute path to the application specific cache directory on
the filesystem designed for storing cached code.
|
ContentResolver
|
getContentResolver()
Return a ContentResolver instance for your application's package.
|
File
|
getDataDir()
Returns the absolute path to the directory on the filesystem where all
private files belonging to this app are stored.
|
File
|
getDatabasePath(String name)
Returns the absolute path on the filesystem where a database created with
openOrCreateDatabase(String, int, CursorFactory) is stored.
|
int
|
getDeviceId()
Gets the device ID this context is associated with.
|
File
|
getDir(String name, int mode)
Retrieve, creating if needed, a new directory in which the application
can place its own custom data files.
|
Display
|
getDisplay()
Get the display this context is associated with.
|
File
|
getExternalCacheDir()
Returns absolute path to application-specific directory on the primary
shared/external storage device where the application can place cache
files it owns.
|
File[]
|
getExternalCacheDirs()
Returns absolute paths to application-specific directories on all
shared/external storage devices where the application can place cache
files it owns.
|
File
|
getExternalFilesDir(String type)
Returns the absolute path to the directory on the primary shared/external
storage device where the application can place persistent files it owns.
|
File[]
|
getExternalFilesDirs(String type)
Returns absolute paths to application-specific directories on all
shared/external storage devices where the application can place
persistent files it owns.
|
File[]
|
getExternalMediaDirs()
This method is deprecated.
These directories still exist and are scanned, but developers
are encouraged to migrate to inserting content into a
MediaStore collection directly, as any app can
contribute new media to MediaStore with no
permissions required, starting in
Build.VERSION_CODES.Q .
|
File
|
getFileStreamPath(String name)
Returns the absolute path on the filesystem where a file created with
openFileOutput(String, int) is stored.
|
File
|
getFilesDir()
Returns the absolute path to the directory on the filesystem where files
created with openFileOutput(String, int) are stored.
|
Executor
|
getMainExecutor()
Return an Executor that will run enqueued tasks on the main
thread associated with this context.
|
Looper
|
getMainLooper()
Return the Looper for the main thread of the current process.
|
File
|
getNoBackupFilesDir()
Returns the absolute path to the directory on the filesystem similar to
getFilesDir() .
|
File
|
getObbDir()
Return the primary shared/external storage directory where this
application's OBB files (if there are any) can be found.
|
File[]
|
getObbDirs()
Returns absolute paths to application-specific directories on all
shared/external storage devices where the application's OBB files (if
there are any) can be found.
|
String
|
getPackageCodePath()
Return the full path to this context's primary Android package.
|
PackageManager
|
getPackageManager()
Return PackageManager instance to find global package information.
|
String
|
getPackageName()
Return the name of this application's package.
|
String
|
getPackageResourcePath()
Return the full path to this context's primary Android package.
|
ContextParams
|
getParams()
Return the set of parameters which this Context was created with, if it
was created via createContext(android.content.ContextParams) .
|
Resources
|
getResources()
Returns a Resources instance for the application's package.
|
SharedPreferences
|
getSharedPreferences(String name, int mode)
Retrieve and hold the contents of the preferences file 'name', returning
a SharedPreferences through which you can retrieve and modify its
values.
|
Object
|
getSystemService(String name)
Return the handle to a system-level service by name.
|
String
|
)">getSystemServiceName(Class<?> serviceClass)
Gets the name of the system-level service that is represented by the specified class.
|
Resources.Theme
|
getTheme()
Return the Theme object associated with this Context.
|
Drawable
|
getWallpaper()
This method is deprecated.
Use WallpaperManager.get() instead.
|
int
|
getWallpaperDesiredMinimumHeight()
This method is deprecated.
Use WallpaperManager.getDesiredMinimumHeight() instead.
|
int
|
getWallpaperDesiredMinimumWidth()
This method is deprecated.
Use WallpaperManager.getDesiredMinimumWidth() instead.
|
void
|
grantUriPermission(String toPackage, Uri uri, int modeFlags)
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.
|
boolean
|
isDeviceProtectedStorage()
Indicates if the storage APIs of this Context are backed by
device-protected storage.
|
boolean
|
isRestricted()
Indicates whether this Context is restricted.
|
boolean
|
moveDatabaseFrom(Context sourceContext, String name)
Move an existing database file from the given source storage context to
this context.
|
boolean
|
moveSharedPreferencesFrom(Context sourceContext, String name)
Move an existing shared preferences file from the given source storage
context to this context.
|
FileInputStream
|
openFileInput(String name)
Open a private file associated with this Context's application package
for reading.
|
FileOutputStream
|
openFileOutput(String name, int mode)
Open a private file associated with this Context's application package
for writing.
|
SQLiteDatabase
|
openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)
Open a new private SQLiteDatabase associated with this Context's
application package.
|
SQLiteDatabase
|
openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory)
Open a new private SQLiteDatabase associated with this Context's
application package.
|
Drawable
|
peekWallpaper()
This method is deprecated.
Use WallpaperManager.peek() instead.
|
void
|
registerComponentCallbacks(ComponentCallbacks callback)
Add a new ComponentCallbacks to the base application of the
Context, which will be called at the same times as the ComponentCallbacks
methods of activities and other components are called.
|
void
|
registerDeviceIdChangeListener(Executor executor, IntConsumer listener)
Adds a new device ID changed listener to the Context , which will be called when
the device association is changed by the system.
|
Intent
|
registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
Register a BroadcastReceiver to be run in the main activity thread.
|
Intent
|
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, int flags)
Register to receive intent broadcasts, with the receiver optionally being
exposed to Instant Apps.
|
Intent
|
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler, int flags)
Register to receive intent broadcasts, to run in the context of
scheduler.
|
Intent
|
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler)
Register to receive intent broadcasts, to run in the context of
scheduler.
|
void
|
removeStickyBroadcast(Intent intent)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
removeStickyBroadcastAsUser(Intent intent, UserHandle user)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
)">revokeSelfPermissionsOnKill(Collection<String> permissions)
Triggers the revocation of one or more permissions for the calling package.
|
void
|
revokeUriPermission(Uri uri, int modeFlags)
Remove all permissions to access a particular content provider Uri
that were previously added with grantUriPermission(String, Uri, int) or any other mechanism.
|
void
|
revokeUriPermission(String targetPackage, Uri uri, int modeFlags)
Remove permissions to access a particular content provider Uri
that were previously added with grantUriPermission(String, Uri, int) for a specific target
package.
|
void
|
sendBroadcast(Intent intent, String receiverPermission, Bundle options)
Broadcast the given intent to all interested BroadcastReceivers, allowing
an optional required permission to be enforced.
|
void
|
sendBroadcast(Intent intent, String receiverPermission)
Broadcast the given intent to all interested BroadcastReceivers, allowing
an optional required permission to be enforced.
|
void
|
sendBroadcast(Intent intent)
Broadcast the given intent to all interested BroadcastReceivers.
|
void
|
sendBroadcastAsUser(Intent intent, UserHandle user)
Version of sendBroadcast(android.content.Intent) that allows you to specify the
user the broadcast will be sent to.
|
void
|
sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission)
Version of sendBroadcast(android.content.Intent, java.lang.String) that allows you to specify the
user the broadcast will be sent to.
|
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission, String receiverAppOp, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of
sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle) that allows you to specify the App Op to enforce restrictions on which receivers
the broadcast will be sent to.
|
void
|
sendOrderedBroadcast(Intent intent, int initialCode, String receiverPermission, String receiverAppOp, BroadcastReceiver resultReceiver, Handler scheduler, String initialData, Bundle initialExtras, Bundle options)
|
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(android.content.Intent) that allows you to
receive data back from the broadcast.
|
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission, Bundle options)
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.
|
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission, Bundle options, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(android.content.Intent) that allows you to
receive data back from the broadcast.
|
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission)
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.
|
void
|
sendOrderedBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of
sendOrderedBroadcast(android.content.Intent, java.lang.String, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle)
that allows you to specify the
user the broadcast will be sent to.
|
void
|
sendStickyBroadcast(Intent intent)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
sendStickyBroadcast(Intent intent, Bundle options)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
sendStickyBroadcastAsUser(Intent intent, UserHandle user)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
This method is deprecated.
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modify them), and many other problems.
The recommended pattern is to use a non-sticky broadcast to report that something
has changed, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
|
setTheme(int resid)
Set the base theme for this context.
|
void
|
setWallpaper(Bitmap bitmap)
This method is deprecated.
Use WallpaperManager.set() instead.
This method requires the caller to hold the permission
Manifest.permission.SET_WALLPAPER .
|
void
|
setWallpaper(InputStream data)
This method is deprecated.
Use WallpaperManager.set() instead.
This method requires the caller to hold the permission
Manifest.permission.SET_WALLPAPER .
|
void
|
startActivities(Intent[] intents, Bundle options)
Launch multiple new activities.
|
void
|
startActivities(Intent[] intents)
Same as startActivities(android.content.Intent[], android.os.Bundle) with no options
specified.
|
void
|
startActivity(Intent intent)
Same as startActivity(android.content.Intent, android.os.Bundle) with no options
specified.
|
void
|
startActivity(Intent intent, Bundle options)
Launch a new activity.
|
ComponentName
|
startForegroundService(Intent service)
Similar to startService(android.content.Intent) , but with an implicit promise that the
Service will call startForeground(int, android.app.Notification) once it begins running.
|
boolean
|
startInstrumentation(ComponentName className, String profileFile, Bundle arguments)
Start executing an Instrumentation class.
|
void
|
startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
Same as startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle)
with no options specified.
|
void
|
startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)
Like startActivity(android.content.Intent, android.os.Bundle) , but taking a IntentSender
to start.
|
ComponentName
|
startService(Intent service)
Request that a given application service be started.
|
boolean
|
stopService(Intent name)
Request that a given application service be stopped.
|
void
|
unbindService(ServiceConnection conn)
Disconnect from an application service.
|
void
|
unregisterComponentCallbacks(ComponentCallbacks callback)
Remove a ComponentCallbacks object that was previously registered
with registerComponentCallbacks(android.content.ComponentCallbacks) .
|
void
|
unregisterDeviceIdChangeListener(IntConsumer listener)
Removes a device ID changed listener from the Context.
|
void
|
unregisterReceiver(BroadcastReceiver receiver)
Unregister a previously registered BroadcastReceiver.
|
void
|
updateServiceGroup(ServiceConnection conn, int group, int importance)
For a service previously bound with bindService(Intent, BindServiceFlags, Executor, ServiceConnection) or a related method, change
how the system manages that service's process in relation to other processes.
|