t startId )
Stop the service if the most recent time it was started was
startId.
From class
| android.content.ContextWrapper
void
|
attachBaseContext(Context base)
Set the b | ase 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 c | ontrol ServiceConnection
callbacks.
boolean
bindService(Intent service, ServiceConnection conn, Context.BindServiceFlags flags)
|
See bindService(Intent,ServiceConnection,int)
Call BindServiceFlags.of(long) | to obtain a BindServiceFlags object.
boolean
bindService(Intent s | erv ice, ServiceConnection conn, int flags)
Connects to an applica | tion service, creating it if needed.
boolean
bindService(Intent service, Context.BindServiceFlags flags, Executor executor, ServiceConnection conn)
| See bindService(Intent,int,Executor,ServiceConnection)
Call BindServiceFlags.of(long) | to obtain a BindServiceFlags object.
boolean
bindServiceAsUser(Intent service, ServiceConnection conn, int flags, UserHandle user)
Bin | ds to a service in the given user in the same manner as bindService(Intent, BindService | Flags, Executor, ServiceConnection).
boolean
bindServiceAsUser(Intent service, ServiceConnection conn, Context.BindServiceFlags flags, UserHandle user)
See bind | Ser viceAsUser(Intent,ServiceConnection,int,UserHandle)
Call BindServiceFlags.of(lo | ng) to obtain a BindServiceFlags object.
int
checkCallingOrSelfPermission(String permissio | n)
Determine whether the calling process of an IPC or you hav | e 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(ListUri uris, int modeFlags)
|
Determine whether the calling process of an IPC or you has be | en granted
permission to access a list of URIs.
int
checkCallingPermission(Strin g permission | )
Determine whether the calling process of an IPC you are han | dling has been
granted a particular permission.
int
checkCallingUriPermission(Uri uri, int mo | deF lags)
Determine whether the calling process and uid has been |
granted permission t access a specific URI.
< >
int[]
,%20int)">checkCallingUriPermissions(ListUri uris | , i nt modeFlags)
Determine whether the calling process and ui | d has been
granted permission to access a list of URIs.
int
checkContentUriPermissionFull(Uri uri, int pid, int uid, int mod | eFl ags)
Determine whether a particular process and uid has be | en granted
permission to access a specific content URI.
int
checkPermission(String permission, int pid, in | t u id)
Determine whether the given permission is allowed for | a particular
process and user ID running in the system.
int
|
checkSelfPermission(String permission)
Determin | e whether you have been granted a particular permission.
int
checkUriPermission(Uri uri, St | rin g readPermission, String writePermission, int pid, int uid, int modeFlags)
|
Check both a Uri and normal permission.
int
checkUriPermission(Uri uri, int p id, int uid, | in t modeFlags)
Determine whether a particular process and uid | has been granted
perm to access a specific URI.
< >
int[]
,%20int,%20int,%20int)">checkUriPermissions(ListUri 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()
T his method i | s d eprecated.
Use WallpaperManager.clear() instead.
This method requires the calle | r to hold the permission
Manifest.permission.SET_WALLPAPER.
Context
createAt | tri butionContext(String attributionTag)
Return a new Context obje | ct for the current Context but attribute to a different tag.
Context
createConfigurationContext(Configuration overr ideConfigura | tio n)
Return a new Context object for the current Context but who | se resources
are adjusted to match the given Configuration.
Context
|
createContext(ContextParams contextParams)
| Creates a context with specific properties and behaviors.
Co | nte xt
createContextForSplit(String splitName)
| Return a new Context object for the given split name.
Context
createDeviceCo | nte xt(int deviceId)
Returns a new Context object from the current | context but with device association
given by the deviceId.
Context
createDeviceProt ectedStorage | Con text()
Return a new Context object for the current Context but | whose storage
APIs are backed by device-protected storage.
Context
createDisplayCon text(Display | di splay)
Returns a new Context object from the current context b | ut 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.
| Co ntext
createWindowContext(int type, Bundle options)
|
Creates a Context for a non-activity window.
Context
crea | teW indowContext(Display display, int type, Bundle options)
Creates | a Context for a non-activity window on the given
Display.
String[]
| da tabaseList()
Returns an array of strings naming the private da | tabases associated with
this Context's application package.
boolean
|
deleteDatabase(String name)
Delete an existing private SQL | iteDatabase associated with this Context's
application package.
boolean |
deleteFile(String name)
Delete the giv | en private file associated with this Context's
application package.
|
boolean
deleteSharedPreferences(Str | ing name)
Delete an existing shared preferences file.
void
enforceCallingOrSelfPermission(String permission, Str ing message) |
If neither you nor the calling process of an IPC you are
han | dling has been granted a particular permission, throw a
SecurityException.
void
enforceCallingOrSelfUriPermission(Uri uri, int m odeFlags, St | rin g 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, St | rin g message)
If the calling process of an IPC you are handlin | g has not been
granted a particular permission, throw a SecurityException.
void
enforceCallingUriPermission(Uri u ri, int mode | Fla gs, 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, in t uid, Strin | g m essage)
If the given permission is not allowed for a partic | ular process
and user ID running in the system, throw a SecurityException.
void
enforceUriPermission(Uri uri, | Str ing readPermission, String writePermission, int pid, int uid, int modeFlags, Stri | ng message)
Enforce both a Uri and normal permission.
void
enforceUriPermission(Uri uri, int pid, int ui d, int modeF | lag s, 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 namin | g the private files associated with
this Context9;s application package.
C | ont ext
getApplicationContext()
Return the conte | xt 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.
|
Attr | ibutionSource
getAttributionSource()
|
String
getAttributionTag()
| Attribution can be used in complex apps to logically | se parate parts of the app.
|
Context
getBaseContext()
|
File
getCacheDir()
Returns t | he 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 s | pecific 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
getDatabas | ePa th(String name)
Returns the absolute path on the filesyste | m 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 i | f 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 prim | ary
shared/external storage device where the application can place cache
files it owns.
File[]
getExterna lCacheDirs() |
Returns absolute paths to application-specific directories on | all
shared/external storage devices where the application can place cache
files it owns.
File
getExternalFile sDir(String | typ e)
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
s | hared/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 | co llection 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 absolu | te path on the filesystem where a file created with
openFileOutput (String, int) is stored.
File
|
getFilesDir()
Returns the absolute path to the direct | ory on the filesystem where files
created with openFileOutput(String, int) are stored.
| Executor
getMainExecutor()
Return a | n Executor that will run enqueued tasks on the main
thread associated with this context.
|
Looper
getMainL | ooper()
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/extern | al 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
getOpPackageN | ame ()
Return the package name that should be used for AppOpsMana | ger calls from
this context, so that app ops manager's uid verification will work with the name.
|
String
getPackageCod | ePath()
Return the full path to this context 's primary Android package.
|
PackageManager
get | PackageManager()
Return PackageManager instance to find global package information.
|
String
|
getPackageName()
Return the name of this application's package.
|
String
getPacka | geResourcePath()
Return the full path to this context's primary Android package.
| ContextParams
getParams()
Return t | he set of parameters which this Context was created with, if it
was created via createContext(ContextParams).
|
Resources
| getResources()
Returns a Resources instance for the application 's package.
SharedPreferences
getSharedPr | efe rences(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
|
g(String name)
< >
Return the handle to a system-level service by name.
|
String
)">getSystemServiceName(Clas | s? 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
getWallpaperDe | siredMinimumHeight()
This method is deprecated.
Use WallpaperManager.getDesiredMinimumHeight() instead.
|
int
getWallpaperD | esiredMinimumWidth()
This method is deprecated.
Use WallpaperManager.getDesiredMinimumWidth () instead.
void
grantUriPermission(Stri | ng 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-p rotected sto | rag e.
|
boolean
isRestricted ()
Indicates whether this Context is restricted.
|
boolean
isUiContext()
| Returns true if the context is a UI context which can access UI components such as
WindowManager , LayoutInflater or
WallpaperManager.
|
boolean
moveDatabaseFrom(Context | sourceContext, String name)
Move an existing database file from the given source storage context to
this context.
|
boolean
moveSharedPreferencesFrom(Context sourceContext, Str | ing name)
Move an existing shared preferences file from the given source storage
context to this context.
|
FileInputStream
openFi | leInput(String name)
Open a private file associated with this Context's application package
for reading.
|
FileOutputStream
openFileOut | put(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, Databa | seErrorHandler 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 Context39;s
application package.
|
| Drawable
peekWallpaper()
This method is deprecated.
Use WallpaperManager.peek() instead.
|
void
| rebindService(ServiceConnection conn, Context.BindServiceFlags flags)
Rebind an application service with updated bind service flags
void
registerComponent Callbacks(Co | mpo nentCallbacks 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
re | gisterReceiver(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.
Int ent
|
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, St | ring broadcastPermission, Handler scheduler, int flags)
Register to receive intent broadcasts, to run in the context of
scheduler.
Inte | nt
registerReceiver(BroadcastReceiver receiver, IntentFilt | er 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 | pro tection (anyone can modify them), and many other problems.
The recommended patte | rn 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 | pro tection (anyone can modify them), and many other problems.
The recommended patte | rn is to use a non-sti broadcast to report that something
h<as cha>nged, with another mechanism for apps to retrieve the current value whenever
desired.
|
void
)&q | uot;>revokeSelfPermissionsOnKill(CollectionString 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
revok | eUr iPermission(String targetPackage, Uri uri, int modeFlags)
R | emove permissions to access a particular content provider Uri
that were previously added with grantUriPermission(String , Uri, int) for a specific target
package.
| voi d
sendBroadcast(Intent intent, String receiverPermissio | n, Bundle options)
Broadcast the given intent to all interested BroadcastReceivers , allowing
an optional required permission to be enforced.
|
void
sendBroadcast(Intent intent, String r | eceiverPermission)
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
sendBroadca | stAsUser(Intent intent, UserHandle user)
Version of sendBroadcast(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(Intent,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, B | und le initialExtras)
Version of
sendOrderedBroadcast(Intent,S | tring,BroadcastReceiver,Handler,int,String,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 receiverPerm | ission, String receiverAppOp, BroadcastReceiver resultReceiver, Handler scheduler, String initialData, Bundle initialExtras, Bundle options)
void
sendOrderedBroadcast(Intent intent, Stri | ng receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int init | ialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(Intent) that allows you to
receive data back from the broadcast.
void
sendOrderedBroadcast(Intent intent, String receiverPermission | , B undle 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 receiverPermi | ssi on, Bundle options, BroadcastReceiver resultReceiver, Handler scheduler, int init | ialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(Intent) that allows you to
receive data back from the broadcast.
void
sendOrderedBroadcast(Intent intent, String re | cei verPermission)
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 sched | ule r, int initialCode, String initialData, Bundle initialExtras)
| Version of
sendOrderedBroadcast(Intent,String,BroadcastReceiver,Handler,int,String,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
c an access th | em) , no protection (anyone can modify them), and many other problems.
The recommend | ed 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
c an access th | em) , no protection (anyone can modify them), and many other problems.
The recommend | ed 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 th | em) , no protection (anyone can modify them), and many other problems.
The recommend | ed 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
c an access th | em) , no protection (anyone can modify them), and many other problems.
The recommend | ed 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
c an access th | em) , no protection (anyone can modify them), and many other problems.
The recommend | ed 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.
| vo id
setWallpaper(Bitmap bitmap)
| This method is deprecated.
Use WallpaperManager.set() instead.
This method requires the caller to hold the permission
Manifest.permission.SET_WALLPAPER .
vo | id
setWallpaper(InputStream data)
| This method is deprecated.
Use WallpaperManager.set() instead.
This method requires the caller to hold the permission
Manifest.pe rmission.SET | _WA LLPAPER.
|
void
startActivities(Intent [] intents, Bundle options)
Launch multiple new activities.
|
| void
startActivities(Intent[] intents)
Same as startActivities(Intent[],Bundle) with no options
specified.
|
|
void
startActivity(Intent intent)
Same as startActivity(Intent,Bundle) wi | th no options
specified.
|
void
startActivity(Intent intent, Bundle options)
Launch a new activity.
ComponentName
|
startForegroundService(Intent service)
| Similar to startService(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(IntentSender,Intent,int,int,int,Bundle)
with no options specified.
v | oid
startIntentSender(IntentSender intent, Intent fillInIntent, int | flagsMask, int flagsValues, int extraFlags, Bundle options)
Like startActivity(Intent,Bundle), but taking a IntentSender
to star | t.
|
ComponentName
startService(Intent service)
Request that a given applica tion service | be started.
|
boolean
stopService(Intent name)
Request that a given appl ication serv | ice be stopped.
|
void
unbindService(ServiceConnection conn)
Disconnect from an application service.
|
void
unregisterComponentCallbacks(Compone | ntCallbacks callback)
Remove a ComponentCallbacks object that was previously registered
with registerComponentCallbacks(ComponentCallbacks).
|
| void
unregisterDeviceIdChangeListener(IntConsumer listener)
Removes a device ID changed listener from the Context.
|
|
void
unregisterReceiv<er(BroadcastReceiver receiv>er)
Unregister a previously registered BroadcastReceiver.
|
void
|
)">updateServiceBindings(CollectionContext.UpdateBindingParams params)
Perform a batch update of existing bindings.
void
updateServiceGroup(ServiceConnection conn, int | gr oup, int i mpo r |
tance)
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.
From class
android.content.Context
boolean
bindIsolatedService(Intent service, int flags, String instanceName, Executor executor, Serv iceConnectio | n c onn)
Variation of bindService(Intent, BindServiceFlags, Execut | or, 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
bindIsolatedService(Intent servic | e, Context.BindServiceFlags flags, String instanceName, Executor executor, ServiceConne | ction conn)
See bindIsolatedService(Intent,int,String,Executor,ServiceConnection)
Call BindServiceFlags.of(long) to obtain a BindServiceFlags object.
|
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, Cont | ext.BindServiceFlags flags)
See bindService(Intent,ServiceConnection,int)
Call BindServiceFlags .of(long) to obtain a BindServiceFlags object.
|
abstract
boole | an
bindService(Intent service, ServiceConnection conn, int flags)
Connects to an application service , creating it if needed.
boolean
|
bindService(Intent service, Context.BindServiceFlags flags, Executor executo | r, ServiceConnection conn)
See bindService(Intent,int,Executor,ServiceConnection)
Call BindServiceFlags.of(long) to obtain a BindServiceFlags object.
boolean
|
bindServiceAsUser(Intent service, ServiceConnection conn, int | flags, UserHandle user)
Binds to a service in the given user in the same manner as bindService(Intent, BindServiceFlags, Executor, ServiceConnection).
boolean
b | ind ServiceAsUser(Intent service, ServiceConnection conn, Context.BindServiceFlags flags, Us | erHandle user)
See bindServiceAsUser(Intent,ServiceConnection,int,UserHandle )
Call BindServiceFlags.of(long) to obtain a BindServiceFlags object.
| abstract
int
| checkCallingOrSelfPermission(String permission)
Determine whether the calling process of an IPC or you have been
granted a particular permission.
abstract
|
int
checkCallingO | rSelfUriPermission(Uri uri, int modeFlags)
Dete<rmi>ne whether the calling process of an IPC or you has been granted
permission to access a specific URI.
|
int[]
,%20int)">checkCallingOrSel | fUriPermissions(ListUri uris, int modeFlags)
Determine whether the calling process of an IPC or you has been granted
permission to access a list of URIs.
|
abstract
int
| checkCallingPermission(String permission)
Determine whether the calling process of an IPC you are handling has been
granted a particular permission.
|
abstract
int
|
checkCalling(Uri uri, int modeFlags)
< >
Determine whether the calling process and uid has been
granted permission to access a specific URI.
|
int[]
,%20 | int)">checkCallingUriPermissions(ListUri uris, int modeFlags)
Determine whether the calling process and uid has been
granted permission to access a list of URIs.
|
int
checkContentUriPerm | issionFull(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.
| abstract
int
c | heckPermission(String permission, int pid, int uid)
Determine whether the given permission is allowed for a particular
process and user ID running in t | he system.
abstract
|
int
checkSelfPermission(String permission)
Determine whether you have been granted a particular permission.
|
abstract
int
|
checkUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid , int modeFlags)
Check both a Uri and normal permission.
| abstract
int
| checkUriPermissi(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(ListUri uris, int pid, int uid, int modeFlags)
Determine whether a particular process and uid has been granted
permission to access a list of URIs.
abstract
|
void
clearWallpaper()
|
This method was deprecated
in API level 15.
Use WallpaperManager.clear () instead.
This method requires the caller to hold the permission
Manifest.permission.SET_WALLPAPER.
|
C | ontext
createAttributionContext(String attributionTag)
Return a new Context object for the current Context but attribute to a different tag.
abstract
|
Context
createCon | figurationContext(Configuration overrideConfiguration)
Return a new Context object for the current Context but whose resources
are adjusted to match | th e given Configuration.
|
Context
createContext(ContextParams contextParams)
Creates a context with specific p | rop erties and behaviors.
abstra | ct
Context
createContextForSplit(String splitName)
Return a new Context object for the given split name.
|
Context |
createDeviceContext(int deviceId)
Returns a new Context object from the current context but with device association
given by the deviceId.
|
abstract
Context
|
createDeviceProtectedStorageContext()
Return a new Context object for the current Context but whose storage
APIs are backed by device-protected storage.
|
abstract
Context
|
createDisplayContext(Display display)
Returns a new Context object from the current context but with resources
adjusted to match the metrics of di | spl ay.
abstract
|
Context
createPackageContext(String packageName, int flags)
Return a new Context obj | ect 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.
|
abstract
| String[]
databaseList()
Returns an array of strings naming the private databases associated with
this Context's application package.
|
abstract
|
boolean
deleteDatabase(String name)
Delete an existing private SQLiteDatabase associated with this Context's
a | ppl ication package.
abstract
|
boolean
deleteFile(String name)
Delete the given private file associa | ted with this Context's
application package.
|
abstract
boolean
deleteSharedPreferences (String name)
Delete an existing shared preferences file.
abstract
|
void
enforceCallingOrSelfP | ermission(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.
abstract |
void
enforceCallingOr | SelfUriPermission(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.
| abstract
void
en | forceCallingPermission(String permission, String message)
If the calling process of an IPC you are handling has not been
granted a particular permission, throw a SecurityException.
| abstract
void
e | nforceCallingUriPermission(Uri uri, int modeFlags, String message)
If the calling process and uid has not been granted
permission to access a specific URI, throw SecurityException.
abstract |
void
enforcePermissio | n(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.
|
abstract
void
|
enforceUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags, String message)
Enforce both a Uri and normal permission.
abstr | act
void
enforceUriPermiss | ion(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 Securi | tyE xception.
abstract
|
String[]
fileList ()
Returns an array of strings naming the private files associated with
this Context | 39; s application package.
abstract
|
Context
getApplicationContext()
Return the context of the single, global | Ap plication object of the
current process.
| abstract
ApplicationInfo
getApplicationInfo()
Return | the full application info for this context's package.
|
abstract
| AssetManager
getAssets()
Return | s an AssetManager instance for the application39;s package.
Attribu | tio nSource
getAttributionSource()
|
String
getAttributionTag()
Attribution can be used in complex app | s t o logically separate parts of the app.
a | bstract
File
getCacheDir()
Returns the absolute path t o the applic | ati on specific cache directory on
the filesystem.
|
abstract
ClassLoader
getClassLoader()
Return a class loader you can use to retrieve classes in this pack | age .
abstract
|
File
getCodeCacheDir ()
Returns the absolute path to the application specific cache directory on
the file | sys tem designed for storing cached code.
|
final
int
getColor(int id)
Returns a color associated with a particular resource ID and styled for
the curre | nt theme.
final
|
ColorStateList
getColorStateList (int id)
Returns a color state list associated with a particular | re source ID and
styled for the current theme.
|
abstract
ContentResolver
getContentResolver()
Return a ContentResolver instance for you r applicatio | n 39;s package.
abstract
|
File
getDataDir ()
Returns the absolute path to the directory on the filesystem where all
private files belonging to this app are stored.
|
abstract
|
File
getDatabasePath(String name)
Returns the absolute path on t he filesyste | m w here a database created with
openOrCreateDatabase(String, int, CursorFactory) is stored. |
int
getDeviceId()
Gets the device ID this context is associ | ate d with.
abstract
|
File
getDir(String name, int mode)
Retr ieve, creati | ng if needed, a new directory in which the application
can place its own custom data files.
|
Display
getDisplay()
Get the display this c | ont ext is associated with.
|
final
Drawable
getDrawable(int id)
Returns a drawable object associated with a particular resource ID and
styled for the current theme.
|
abstract
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.
|
abstract
File[]
|
getExternalCacheDirs()
Returns absolute paths to application-specific directories on all
shared/external storage devices where the application can place cache
files it owns.
|
abstract
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.
|
abstract
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.
abstract
File[]
getExternalMediaDirs()
This method was deprecated
in API level 30.
Thes e directorie | s s till exist and are scanned, but developers
are encouraged to migrate to inse | rting content into a
MediaStore collection directly, as any app can
contribute new media to MediaStore with no
permissions required, starting in
Build.VERSION_ | COD ES.Q.
abstract
|
File
getFileStreamPath (String name)
Returns the absolute path on the filesystem where a file created with
openFileOutput(String, int) is | st ored.
abstract
|
File
getFilesDir ()
Returns the absolute path to the directory on the filesystem where files
created with op | enF ileOutput(String, int) are stored.
|
Executor
getMainExecutor()
Return an Executor that will | ru n enqueued tasks on the main
thread associated with this context.
|
abstract
Looper
getMainLooper()
Return the Looper for | the main thread of the current process.
| abstract
File
getNoBackupFilesDir()
Returns the absolute path to the directory on the filesystem similar to
| ge tFilesDir().
abstract
|
File
getObbDir()
Return the primary shared/external storage directory where this
application's OBB files (if there are any) can be found.
|
abstract
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.
|
Stri | ng
getOpPackageName()
Return the package name that should be used for AppOpsManager calls from
this contex | t, so that app ops manager's uid verification will work with the name.
|
abstract
String
getPackageCodePath()
| Re turn the full path to this context's primary Android package.
|
abstract
PackageManager
getPackag | eMa nager()
Return PackageManager instance to find global package informa | tion.
abstract
String
getPackageN | ame ()
Return the name of this application's package.
|
abstract
String
getPackageResourcePath()
Return the full path to th | is context's primary Android package.
|
ContextParams
getParams()
Return the se t of paramet | ers which this Context was created with, if it
was created via createContext(ContextParams).
|
abstract
Resources
getResources()
Returns a Resources instance for the application's package.
|
abstract
SharedPref | erences
getSharedPreferences(String name , int mode)
Retrieve and hold the contents of the preferences file 'name', ret | urn ing
a SharedPreferences through which you can retrieve and modify its
values.
|
final
String
getString(int resId)
Returns a localized string from the application's package9;s
default string table.
|
final
<S>tring
|
getSt(int resId, Object...< >formatArgs)
Returns a localized formatted string from the application's package's
defa | ult string table, substituting the format arguments as defined in
Formatter and String.format | (String, Object).
final
T
T
| )&q uot;>getSystemService(ClassT serviceClass)
Return the handle to a | system-level service b class.
< >
abstract
Object
getSystemService(String name | )
Return the handle to a system-level service by name.
|
abstract
String
)">getSystemServiceName(Class? serviceClass )
|
Gets the name of the system-level service that is represented by the specified class.
|
final
CharSequence
| getText(int resId)
Return a localized, styled CharSequence from the applicati | on's package's
default string table.
abstract
|
Resources.Theme
getTheme()
Return the | Theme object associated with this Context.
Context.BindServiceFlags
|
getUpdateableFlags()
Gets the list of bind flags that ma | y be updated (i.e.
abstract
Drawable
getWallpaper()
This method was | de precated
in API level 15.
Use WallpaperManager.get() instead.
|
abstract
int
getWallpaperDesiredMinimumHeight()
This method was deprecated
| in API level 15.
Use WallpaperManager.getDesiredMinimumHeight() instead.
|
abstract
int
getWallpaperDesiredMinimumWidth()
This method was deprecated
in API level 15.
Use WallpaperManager.getDesiredMinimum Width() inst | ead .
abstract
|
void
grantUriPermission(String toPackage, Uri uri, int modeFlags)
Grant permission to access a specific Uri to anothe | r p ackage, regardless
of whether that package has general permission to access the Uri | 's
content provider.
abstract
| boolean
isDeviceProtectedStorage()
| Indicates if the storage APIs of this Context are backed by
device-protected storage.
boolean
| i sRestricted()
Indicates whether this Context is restricted.
|
boolean
isUiContext()
Returns true if the context is a UI context which | ca n access UI components such as
WindowManager, LayoutInflater or
WallpaperManager.
|
abstract
boolean
moveDatabaseFrom(Context sourceContext, String name)
Move an existing da | tab ase file from the given source storage context to
this context.
|
abstract
boolean
moveSharedPreferencesFrom(Context sourceContext, String nam e)
|
Move an existing shared preferences file from the given source storage
context to | this context.
final
TypedArray
obtainStyledAttributes(AttributeSet set, int[] attrs)
|
Retrieve styled attribute information in this Context's theme.
|
final
TypedArray
obtainStyledAttributes(AttributeSet set, int[] attrs, | in t defStyleAttr, int defStyleRes)
Retrieve styled attribute information | in this Context's theme.
final
TypedArray
| obtainStyledAttributes(int resid, int[] attrs)
Retrieve styled attribute info | rmation in this Context's theme.
final
TypedArray
ob | tai nStyledAttributes(int[] attrs)
Retrieve styled attribute information in this Co | ntext9;s theme.
abstract
FileInputStream
openFileInput(String na | me)
Open a private file associated with this Context's application package
| for reading.
abstract
FileOutputStream
openFileOutput(String name, int mode)
Open a private file associated with this Context& | #39 ;s application package
for writing.
abstra | ct
SQLiteDatabase
openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)
Open a new p | riv ate SQLiteDatabase associated with this Context's
application package.
|
abstract
SQLiteDatabase
openOrCreateDatabase(String name, int mode, SQLiteD | ata base.CursorFactory factory)
Open a new private SQLiteDataba | se associated with this Context';s
application package.
abstract
Drawable
| p eekWallpaper()
This method was deprecated
in A | PI level 15.
Use WallpaperManager.peek() instead.
void
rebindService(ServiceConnection conn, Context.BindServiceFlags flags)
Rebind an application service with upda | ted bind service flags
|
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 Compone | ntC allbacks
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 associ | ation is changed by the system.
abstract
Intent
registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
|
Register a BroadcastReceiver to be run in the main activity thread.
|
abstract
Intent
registerReceiver(BroadcastReceiver receiver , IntentFilter filter, int flags)
Register to receive intent broadcasts, w | ith the receiver optionally being
exposed to Instant Apps.
|
abstract
Intent
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler, int flags)
Regis | ter to receive intent broadcasts, to run in the context of
scheduler.
|
abstract
Intent
registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler)
Register to receive intent broadcasts, to run in the context of
scheduler.
abstract
void
removeStickyBroadcast(Intent i | nte nt)
This method was deprecated
in API level 21.
St | icky 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.
abstract
void
removeStickyBroadcastAsUser(Intent intent , UserHandle | us er)
This method was deprecated
in API level 21 | .
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 recommend | ed pattern is to use a non-sticky broadcast to report that something
has changed, w | ith another mechanism for apps to retrieve the current value wh<enever>
desired.
void
| revokeSelfPermissionOnKill(String permName)
Triggers the asynchro | nous revocation of a runtime permission.
void
)">revokeSelfPermissionsOnKill(CollectionString permissions)
Triggers th | e r evocation of one or more permissions for the calling package.
|
abstract
void
revokeUriPermission(Uri uri, int modeFlags)
Remove all permissions to access a particular content provider Uri
that were previously added with grantU riPermission | (St ring, Uri, int) or any other mechanism.
|
abstract
void
revokeUriPermission(String toPackage, Uri uri, int modeFlags)
Remove permissions to access a particular content provider Uri
that w ere previous | ly added with grantUriPermission(String, Uri, int) for a specific target
package.
|
void
sendBroadcast(Intent intent, String receiverPermission, Bundle options)
Broadcast the given intent to al | l i nterested BroadcastReceivers, allowing
an optional required permission to be enforced.
|
abstract
void
sendBroadcast (Intent inte | nt, String receiverPermission)
Broadcast the given intent to all inter | ested BroadcastReceivers, allowing
an optional required permission to be enforced.
abstract
void
| se ndBroadcast(Intent intent)
Broadcast the given intent to all intere | sted BroadcastReceivers.
abstract
void
sendBroadcastAsUser(Intent intent, UserHandle user)
Version of sendBro | adc ast(Intent) that allows you to specify the
user the broadcast will be sent to.
|
abstract
void
sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission)
Version of sendBroadcast (Intent,Stri | ng) that allows you to specify the
user the broadcast will be sent to.
|
void
sendBroadcastWithMultiplePermissions(Intent intent, String[] receiverPermissions)
Broadcast the given intent to all interested BroadcastReceivers, allowing
an array of required permissions to be enforced.
void
|
sendOrderedBroadcast(Intent intent, String receiverPermission, String receiverAppOp, | BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of
sendOrderedBroadcast(Intent,String,BroadcastReceiver,Handler,int,String,Bundle) that allows you to specify the App Op to enforce restrictions on which receivers
the broadcast w ill be sent | to.
abstract
|
void
sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(Intent) that allows you to
receive data back from the broadcas t.
|
| 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 rec eivers.
|
| void
sendOrderedBroadcast(Intent intent, String receiverPermission, Bundle options , BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of sendBroadcast(Intent) that allows you to
receive data back from the broadcast.
|
abstract
|
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.
abstract
|
void
sendOrderedBroadcastAsUser(Intent intent, | UserHandle user, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of
sendOrderedBroadcast(Intent,String,BroadcastReceiver,Handler,int,String,Bundle)
that allows you to specify the
user the broadcast will be sent to.
abstract
void
sendStic kyBroadcast( | Int ent intent)
This method was deprecated
in API | level 21.
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, B | und le options)
This method was deprecated
in API level 31 | .
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.
abstract
void
sendStickyBroadcastAsUser(Intent intent, Us | erH andle user)
This method was deprecated
in API level 21 | .
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.
abstract
void
sendStickyOrderedBroadcast(Intent intent, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialD ata, Bundle | ini tialExtras)
This method was deprecated
in API level 21 | .
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.
abstract
void
sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle | ini tialExtras)
This method was deprecated
in API level 21 | .
Sticky broadcasts should not be used. They provide no security (anyone
can access them), no protection (anyone can modi | fy 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.
abstract
void
setTheme(int r esid)
|
Set the base theme for this context.
|
abstract
void
setWallpaper(Bitmap bitmap)
This method was deprecated
in API level 15.
Use WallpaperManager.set() instead.
This method re quires the call er to hold t | he permission
Manifest.permission.SET_WALLPAPER.
|
abstract
void
setWallpaper(InputStream data)
| This method was deprecated
in API level 15.
Use WallpaperManager.set() inste | ad.
This method requires the caller to hold the permission
Manifest.permission .SET_WALLPAPER.
abstract
|
void
startActivities(Intent[] inte | nts, Bundle options)
Launch multiple new activities.
abstract
|
void
startActivities(Intent[] intents)
|
Same as startActivities(Intent[],Bundle) with no options
specified.
| a bstract
void
startActivity(I | ntent intent)
Same as startActivity(Intent,Bundle) with no options
specified.
abstract
void
startActivity(Intent intent, | Bun dle options)
Launch a new activity.
|
abstract
ComponentName
startForegroundService (Intent service)
Similar to startServ | ice (Intent), but with an implicit promise that the
Service will call startForeground(int, a | ndroid.app.Notification) once it begins running.
abstract
boolean
startInstrumentation(ComponentName className, String profileFile, Bundle argumen | ts)
Start executing an Instrumentation class.
|
abstract
void
startIntentSender(IntentSender intent, Intent fillInIntent , int flagsMask, int flagsValues, int extraFlags)
Same as startIntentS | end er(IntentSender,Intent,int,int,int,Bundle)
with no options specified.
|
abstract
void
startIntentSender(IntentSen der intent, | Int ent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)
|
Like startActivity(Intent,Bundle), but taking a IntentSender
to start.
abstract
|
ComponentName
startServi | ce(Intent service)
Request that a given application service be started.
| a bstract
boolean
| stopService(Intent service)
Request that a given application service be stopped .
abstract
void
| unb indService(ServiceConnection conn)
Disconnect from an appli | cation service.
void
unregisterComponentC allbacks(Com | pon entCallbacks callback)
Remove a ComponentCallbacks object that was | previously registered
with registerComponentCallbacks(ComponentCallbacks).
| void
unregisterDeviceIdChangeListener(IntConsumer li | stener)
Removes a device ID changed< listener from the Context.>
abstract
| void
unregisterReceiver(BroadcastReceiver receiver | )
Unregister a previously registered BroadcastReceiver.
void
)">updateServiceBindings(CollectionContext.UpdateBindingParams params)
Perform a batch update of e xisting bind | ing s.
|