Service Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.
[Android.Runtime.Register("android/app/Service", DoNotGenerateAcw=true)]
public abstract class Service : Android.Content.ContextWrapper, Android.Content.IComponentCallbacks2, IDisposable
[<Android.Runtime.Register("android/app/Service", DoNotGenerateAcw=true)>]
type Service = class
inherit ContextWrapper
interface IComponentCallbacks
interface IJavaObject
interface IDisposable
interface IJavaPeerable
interface IComponentCallbacks2
- Inheritance
- Derived
- Attributes
- Implements
Remarks
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding <service> declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService(). Note that services, like other application objects, run in the main thread of their hosting process. This means that, if your service is going to do any CPU intensive (such as MP3 playback) or blocking (such as networking) operations, it should spawn its own thread in which to do that work. More information on this can be found in Processes and Threads. The JobIntentService class is available as a standard implementation of Service that has its own thread where it schedules its work to be done.
Topics covered here: What is a Service? Service Lifecycle Permissions Process Lifecycle Local Service Sample Remote Messenger Service Sample Developer Guides For a detailed discussion about how to create services, read the Services developer guide.
Most confusion about the Service class actually revolves around what it is not:
- A Service is not a separate process. The Service object itself does not imply it is running in its own process; unless otherwise specified, it runs in the same process as the application it is part of.:
- A Service is not a thread. It is not a means itself to do work off of the main thread (to avoid Application Not Responding errors).:
Thus a Service itself is actually very simple, providing two main features:
- A facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application). This corresponds to calls to Context.startService(), which ask the system to schedule work for the service, to be run until the service or someone else explicitly stop it.:
- A facility for an application to expose some of its functionality to other applications. This corresponds to calls to Context.bindService(), which allows a long-standing connection to be made to the service in order to interact with it.:
When a Service component is actually created, for either of these reasons, all that the system actually does is instantiate the component and call its onCreate() and any other appropriate callbacks on the main thread. It is up to the Service to implement these with the appropriate behavior, such as creating a secondary thread in which it does its work.
Note that because Service itself is so simple, you can make your interaction with it as simple or complicated as you want: from treating it as a local Java object that you make direct method calls on (as illustrated by Local Service Sample), to providing a full remoteable interface using AIDL.
There are two reasons that a service can be run by the system. If someone calls Context.startService() then the system will retrieve the service (creating it and calling its onCreate() method if needed) and then call its onStartCommand(Intent, int, int) method with the arguments supplied by the client. The service will at this point continue running until Context.stopService() or stopSelf() is called. Note that multiple calls to Context.startService() do not nest (though they do result in multiple corresponding calls to onStartCommand()), so no matter how many times it is started a service will be stopped once Context.stopService() or stopSelf() is called; however, services can use their stopSelf(int) method to ensure the service is not stopped until started intents have been processed. For started services, there are two additional major modes of operation they can decide to run in, depending on the value they return from onStartCommand(): START_STICKY is used for services that are explicitly started and stopped as needed, while START_NOT_STICKY or START_REDELIVER_INTENT are used for services that should only remain running while processing any commands sent to them. See the linked documentation for more detail on the semantics. Clients can also use Context.bindService() to obtain a persistent connection to a service. This likewise creates the service if it is not already running (calling onCreate() while doing so), but does not call onStartCommand(). The client will receive the IBinder object that the service returns from its onBind(Intent) method, allowing the client to then make calls back to the service. The service will remain running as long as the connection is established (whether or not the client retains a reference on the service's IBinder). Usually the IBinder returned is for a complex interface that has been written in aidl. A service can be both started and have connections bound to it. In such a case, the system will keep the service running as long as either it is started or there are one or more connections to it with the Context.BIND_AUTO_CREATE flag. Once neither of these situations hold, the service's onDestroy() method is called and the service is effectively terminated. All cleanup (stopping threads, unregistering receivers) should be complete upon returning from onDestroy(). Permissions Global access to a service can be enforced when it is declared in its manifest's <service> tag. By doing so, other applications will need to declare a corresponding <uses-permission> element in their own manifest to be able to start, stop, or bind to the service. As of Build.VERSION_CODES.GINGERBREAD, when using Context.startService(Intent), you can also set Intent.FLAG_GRANT_READ_URI_PERMISSION and/or Intent.FLAG_GRANT_WRITE_URI_PERMISSION on the Intent. This will grant the Service temporary access to the specific URIs in the Intent. Access will remain until the Service has called stopSelf(int) for that start command or a later one, or until the Service has been completely stopped. This works for granting access to the other apps that have not requested the permission protecting the Service, or even when the Service is not exported at all. In addition, a service can protect individual IPC calls into it with permissions, by calling the ContextWrapper.checkCallingPermission(String) method before executing the implementation of that call. See the Security and Permissions document for more information on permissions and security in general. Process Lifecycle The Android system will attempt to keep the process hosting a service around as long as the service has been started or has clients bound to it. When running low on memory and needing to kill existing processes, the priority of a process hosting the service will be the higher of the following possibilities: If the service is currently executing code in its onCreate(), onStartCommand(), or onDestroy() methods, then the hosting process will be a foreground process to ensure this code can execute without being killed. If the service has been started, then its hosting process is considered to be less important than any processes that are currently visible to the user on-screen, but more important than any process not visible. Because only a few processes are generally visible to the user, this means that the service should not be killed except in low memory conditions. However, since the user is not directly aware of a background service, in that state it is considered a valid candidate to kill, and you should be prepared for this to happen. In particular, long-running services will be increasingly likely to kill and are guaranteed to be killed (and restarted if appropriate) if they remain started long enough. If there are clients bound to the service, then the service's hosting process is never less important than the most important client. That is, if one of its clients is visible to the user, then the service itself is considered to be visible. The way a client's importance impacts the service's importance can be adjusted through Context.BIND_ABOVE_CLIENT, Context.BIND_ALLOW_OOM_MANAGEMENT, Context.BIND_WAIVE_PRIORITY, Context.BIND_IMPORTANT, and Context.BIND_ADJUST_WITH_ACTIVITY. A started service can use the startForeground(int,Notification) API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. (It is still theoretically possible for the service to be killed under extreme memory pressure from the current foreground application, but in practice this should not be a concern.) Note this means that most of the time your service is running, it may be killed by the system if it is under heavy memory pressure. If this happens, the system will later try to restart the service. An important consequence of this is that if you implement onStartCommand() to schedule work to be done asynchronously or in another thread, then you may want to use START_FLAG_REDELIVERY to have the system re-deliver an Intent for you so that it does not get lost if your service is killed while processing it. Other application components running in the same process as the service (such as an Activity) can, of course, increase the importance of the overall process beyond just the importance of the service itself. Local Service Sample One of the most common uses of a Service is as a secondary component running alongside other parts of an application, in the same process as the rest of the components. All components of an .apk run in the same process unless explicitly stated otherwise, so this is a typical situation. When used in this way, by assuming the components are in the same process, you can greatly simplify the interaction between them: clients of the service can simply cast the IBinder they receive from it to a concrete class published by the service. An example of this use of a Service is shown here. First is the Service itself, publishing a custom class when bound:
public class LocalService extends Service {
private NotificationManager mNM;
// Unique Identification Number for the Notification.
// We use it on Notification start, and to cancel it.
private int NOTIFICATION = R.string.local_service_started;
/**
* Class for clients to access. Because we know this service always
* runs in the same process as its clients, we don't need to deal with
* IPC.
*/
public class LocalBinder extends Binder {
LocalService getService() {
return LocalService.this;
}
}
@Override
public void onCreate() {
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// Display a notification about us starting. We put an icon in the status bar.
showNotification();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("LocalService", "Received start id " + startId + ": " + intent);
return START_NOT_STICKY;
}
@Override
public void onDestroy() {
// Cancel the persistent notification.
mNM.cancel(NOTIFICATION);
// Tell the user we stopped.
Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT).show();
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
// This is the object that receives interactions from clients. See
// RemoteService for a more complete example.
private final IBinder mBinder = new LocalBinder();
/**
* Show a notification while this service is running.
*/
private void showNotification() {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.local_service_started);
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, LocalServiceActivities.Controller.class), 0);
// Set the info for the views that show in the notification panel.
Notification notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.stat_sample) // the status icon
.setTicker(text) // the status text
.setWhen(System.currentTimeMillis()) // the time stamp
.setContentTitle(getText(R.string.local_service_label)) // the label of the entry
.setContentText(text) // the contents of the entry
.setContentIntent(contentIntent) // The intent to send when the entry is clicked
.build();
// Send the notification.
mNM.notify(NOTIFICATION, notification);
}
}
With that done, one can now write client code that directly accesses the running service, such as:
/**
* Example of binding and unbinding to the local service.
* bind to, receiving an object through which it can communicate with the service.
*
* Note that this is implemented as an inner class only keep the sample
* all together; typically this code would appear in some separate class.
*/
public static class Binding extends Activity {
// Don't attempt to unbind from the service unless the client has received some
// information about the service's state.
private boolean mShouldUnbind;
// To invoke the bound service, first make sure that this value
// is not null.
private LocalService mBoundService;
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
// This is called when the connection with the service has been
// established, giving us the service object we can use to
// interact with the service. Because we have bound to a explicit
// service that we know is running in our own process, we can
// cast its IBinder to a concrete class and directly access it.
mBoundService = ((LocalService.LocalBinder)service).getService();
// Tell the user about this for our demo.
Toast.makeText(Binding.this, R.string.local_service_connected,
Toast.LENGTH_SHORT).show();
}
public void onServiceDisconnected(ComponentName className) {
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
// Because it is running in our same process, we should never
// see this happen.
mBoundService = null;
Toast.makeText(Binding.this, R.string.local_service_disconnected,
Toast.LENGTH_SHORT).show();
}
};
void doBindService() {
// Attempts to establish a connection with the service. We use an
// explicit class name because we want a specific service
// implementation that we know will be running in our own process
// (and thus won't be supporting component replacement by other
// applications).
if (bindService(new Intent(Binding.this, LocalService.class),
mConnection, Context.BIND_AUTO_CREATE)) {
mShouldUnbind = true;
} else {
Log.e("MY_APP_TAG", "Error: The requested service doesn't " +
"exist, or this client isn't allowed access to it.");
}
}
void doUnbindService() {
if (mShouldUnbind) {
// Release information about the service's state.
unbindService(mConnection);
mShouldUnbind = false;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
doUnbindService();
}
}
Remote Messenger Service Sample If you need to be able to write a Service that can perform complicated communication with clients in remote processes (beyond simply the use of Context.startService to send commands to it), then you can use the Messenger class instead of writing full AIDL files. An example of a Service that uses Messenger as its client interface is shown here. First is the Service itself, publishing a Messenger to an internal Handler when bound:
public class MessengerService extends Service {
/** For showing and hiding our notification. */
NotificationManager mNM;
/** Keeps track of all current registered clients. */
ArrayList<Messenger> mClients = new ArrayList<Messenger>();
/** Holds last value set by a client. */
int mValue = 0;
/**
* Command to the service to register a client, receiving callbacks
* from the service. The Message's replyTo field must be a Messenger of
* the client where callbacks should be sent.
*/
static final int MSG_REGISTER_CLIENT = 1;
/**
* Command to the service to unregister a client, ot stop receiving callbacks
* from the service. The Message's replyTo field must be a Messenger of
* the client as previously given with MSG_REGISTER_CLIENT.
*/
static final int MSG_UNREGISTER_CLIENT = 2;
/**
* Command to service to set a new value. This can be sent to the
* service to supply a new value, and will be sent by the service to
* any registered clients with the new value.
*/
static final int MSG_SET_VALUE = 3;
/**
* Handler of incoming messages from clients.
*/
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REGISTER_CLIENT:
mClients.add(msg.replyTo);
break;
case MSG_UNREGISTER_CLIENT:
mClients.remove(msg.replyTo);
break;
case MSG_SET_VALUE:
mValue = msg.arg1;
for (int i=mClients.size()-1; i>=0; i--) {
try {
mClients.get(i).send(Message.obtain(null,
MSG_SET_VALUE, mValue, 0));
} catch (RemoteException e) {
// The client is dead. Remove it from the list;
// we are going through the list from back to front
// so this is safe to do inside the loop.
mClients.remove(i);
}
}
break;
default:
super.handleMessage(msg);
}
}
}
/**
* Target we publish for clients to send messages to IncomingHandler.
*/
final Messenger mMessenger = new Messenger(new IncomingHandler());
@Override
public void onCreate() {
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// Display a notification about us starting.
showNotification();
}
@Override
public void onDestroy() {
// Cancel the persistent notification.
mNM.cancel(R.string.remote_service_started);
// Tell the user we stopped.
Toast.makeText(this, R.string.remote_service_stopped, Toast.LENGTH_SHORT).show();
}
/**
* When binding to the service, we return an interface to our messenger
* for sending messages to the service.
*/
@Override
public IBinder onBind(Intent intent) {
return mMessenger.getBinder();
}
/**
* Show a notification while this service is running.
*/
private void showNotification() {
// In this sample, we'll use the same text for the ticker and the expanded notification
CharSequence text = getText(R.string.remote_service_started);
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, Controller.class), 0);
// Set the info for the views that show in the notification panel.
Notification notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.stat_sample) // the status icon
.setTicker(text) // the status text
.setWhen(System.currentTimeMillis()) // the time stamp
.setContentTitle(getText(R.string.local_service_label)) // the label of the entry
.setContentText(text) // the contents of the entry
.setContentIntent(contentIntent) // The intent to send when the entry is clicked
.build();
// Send the notification.
// We use a string id because it is a unique number. We use it later to cancel.
mNM.notify(R.string.remote_service_started, notification);
}
}
If we want to make this service run in a remote process (instead of the standard one for its .apk), we can use android:process in its manifest tag to specify one:
<service android:name=".app.MessengerService"
android:process=":remote" />
Note that the name "remote" chosen here is arbitrary, and you can use other names if you want additional processes. The ':' prefix appends the name to your package's standard process name. With that done, clients can now bind to the service and send messages to it. Note that this allows clients to register with it to receive messages back as well:
/**
* Example of binding and unbinding to the remote service.
* This demonstrates the implementation of a service which the client will
* bind to, interacting with it through an aidl interface.
*
* Note that this is implemented as an inner class only keep the sample
* all together; typically this code would appear in some separate class.
*/
public static class Binding extends Activity {
/** Messenger for communicating with service. */
Messenger mService = null;
/** Flag indicating whether we have called bind on the service. */
boolean mIsBound;
/** Some text view we are using to show state information. */
TextView mCallbackText;
/**
* Handler of incoming messages from service.
*/
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MessengerService.MSG_SET_VALUE:
mCallbackText.setText("Received from service: " + msg.arg1);
break;
default:
super.handleMessage(msg);
}
}
}
/**
* Target we publish for clients to send messages to IncomingHandler.
*/
final Messenger mMessenger = new Messenger(new IncomingHandler());
/**
* Class for interacting with the main interface of the service.
*/
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
// This is called when the connection with the service has been
// established, giving us the service object we can use to
// interact with the service. We are communicating with our
// service through an IDL interface, so get a client-side
// representation of that from the raw service object.
mService = new Messenger(service);
mCallbackText.setText("Attached.");
// We want to monitor the service for as long as we are
// connected to it.
try {
Message msg = Message.obtain(null,
MessengerService.MSG_REGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
// Give it some value as an example.
msg = Message.obtain(null,
MessengerService.MSG_SET_VALUE, this.hashCode(), 0);
mService.send(msg);
} catch (RemoteException e) {
// In this case the service has crashed before we could even
// do anything with it; we can count on soon being
// disconnected (and then reconnected if it can be restarted)
// so there is no need to do anything here.
}
// As part of the sample, tell the user what happened.
Toast.makeText(Binding.this, R.string.remote_service_connected,
Toast.LENGTH_SHORT).show();
}
public void onServiceDisconnected(ComponentName className) {
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
mService = null;
mCallbackText.setText("Disconnected.");
// As part of the sample, tell the user what happened.
Toast.makeText(Binding.this, R.string.remote_service_disconnected,
Toast.LENGTH_SHORT).show();
}
};
void doBindService() {
// Establish a connection with the service. We use an explicit
// class name because there is no reason to be able to let other
// applications replace our component.
bindService(new Intent(Binding.this,
MessengerService.class), mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true;
mCallbackText.setText("Binding.");
}
void doUnbindService() {
if (mIsBound) {
// If we have received the service, and hence registered with
// it, then now is the time to unregister.
if (mService != null) {
try {
Message msg = Message.obtain(null,
MessengerService.MSG_UNREGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
} catch (RemoteException e) {
// There is nothing special we need to do if the service
// has crashed.
}
}
// Detach our existing connection.
unbindService(mConnection);
mIsBound = false;
mCallbackText.setText("Unbinding.");
}
}
}
Android reference for android.app.Service.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
| Name | Description |
|---|---|
| Service() |
Initializes a service object before its base context is attached. |
| Service(IntPtr, JniHandleOwnership) |
Initializes a managed representation of an existing Java Native Interface object. |
Fields
| Name | Description |
|---|---|
| AccessibilityService |
Use with |
| AccountService |
Use with |
| ActivityService |
Use with |
| AdvancedProtectionService |
Use with |
| AlarmService |
Use with |
| AppFunctionService |
Use with |
| AppInteractionService |
Use with |
| AppOpsService |
Use with |
| AppSearchService |
Use with |
| AppwidgetService |
Use with |
| AudioService |
Use with |
| AuthenticationPolicyService |
Use with |
| AutofillService |
Use with |
| BatteryService |
Use with |
| BindAllowActivityStarts |
Obsolete.
Flag for |
| BindExternalServiceLong |
Works in the same way as |
| BindNotPerceptible |
Obsolete.
Flag for |
| BindPackageIsolatedProcess |
Obsolete.
Flag for |
| BindSharedIsolatedProcess |
Obsolete.
Flag for |
| BiometricService |
Use with |
| BlobStoreService |
Use with |
| BluetoothService |
Use with |
| BugreportService |
Service to capture a bugreport. (Inherited from Context) |
| CameraService |
Use with |
| CaptioningService |
Use with |
| CarrierConfigService |
Use with |
| ChooserService |
Use with |
| ClipboardService |
Use with |
| CompanionDeviceService |
Use with |
| ConnectivityDiagnosticsService |
Use with |
| ConnectivityService |
Use with |
| ConsumerIrService |
Use with |
| ContactKeysService |
Use with |
| ContentRestrictionService |
Use with |
| CredentialService |
Use with |
| CrossProfileAppsService |
Use with |
| DeviceIdDefault |
The default device ID, which is the ID of the primary (non-virtual) device. (Inherited from Context) |
| DeviceIdInvalid |
Invalid device ID. (Inherited from Context) |
| DeviceLockService |
Use with |
| DevicePolicyService |
Use with |
| DisplayHashService |
Use with |
| DisplayService |
Use with |
| DomainVerificationService |
Use with |
| DownloadService |
Use with |
| DropboxService |
Use with |
| EuiccService |
Use with |
| FileIntegrityService |
Use with |
| FileService |
Use with |
| FingerprintService |
Use with |
| GameService |
Use with |
| GrammaticalInflectionService |
Use with |
| HardwarePropertiesService |
Use with |
| HealthconnectService |
Use with |
| HidService |
Use with |
| InputMethodService |
Use with |
| InputService |
Use with |
| IpsecService |
Use with |
| JobSchedulerService |
Use with |
| KeychainService |
Use with |
| KeyguardService |
Use with |
| KeystoreService |
Use with |
| LauncherAppsService |
Use with |
| LayoutInflaterService |
Use with |
| LocaleService |
Use with |
| LocationService |
Use with |
| MediaCommunicationService |
Use with |
| MediaMetricsService |
Use with |
| MediaProjectionService |
Use with |
| MediaQualityService |
Use with |
| MediaRouterService |
Use with |
| MediaSessionService |
Use with |
| MemoryBudgetService |
Use with |
| MidiService |
Use with |
| MultisensoryManagerService |
Use with |
| NetworkStatsService |
Use with |
| NfcService |
Use with |
| NotificationService |
Use with |
| NpuService |
Use with |
| NsdService |
Use with |
| OverlayService |
Use with |
| PccSandboxService |
Use with |
| PeopleService |
Use with |
| PerformanceHintService |
Use with |
| PersistentDataBlockService |
Use with |
| PowerService |
Use with |
| PrintService |
|
| ProfilingService |
Use with |
| ReceiverExported |
Obsolete.
Flag for |
| ReceiverNotExported |
Obsolete.
Flag for |
| ReceiverVisibleToInstantApps |
Obsolete.
Flag for |
| RestrictionsService |
Use with |
| RoleService |
Use with |
| SatelliteService |
Use with |
| SearchService |
Use with |
| SecurityStateService |
Use with |
| SensorService |
Use with |
| SerialService |
Use with |
| ShortcutService |
Use with |
| StatusBarService |
Use with |
| StopForegroundDetach |
Obsolete.
Selector for |
| StopForegroundLegacy |
Selector for |
| StopForegroundRemove |
Obsolete.
Selector for |
| StorageService |
Use with |
| StorageStatsService |
Use with |
| SystemHealthService |
Use with |
| TelecomService |
Use with |
| TelephonyImsService |
Use with |
| TelephonyPhoneNumberService |
Use with |
| TelephonyService |
Use with |
| TelephonySubscriptionService |
Use with |
| TetheringService |
Use with |
| TextClassificationService |
Use with |
| TextServicesManagerService |
Use with |
| TimeManagerService |
Use with |
| TvAdService |
Use with |
| TvInputService |
Use with |
| TvInteractiveAppService |
Use with |
| UiModeService |
Use with |
| UsageStatsService |
Use with |
| UsbService |
Use with |
| UserService |
Use with |
| VibratorManagerService |
Use with |
| VibratorService |
Use with |
| VirtualDeviceService |
Use with |
| VpnManagementService |
Use with |
| WallpaperService |
Use with |
| WebAppService |
Use with |
| WifiAwareService |
Use with |
| WifiP2pService |
Use with |
| WifiRttRangingService |
Use with |
| WifiService |
Use with |
| WindowService |
Use with |
Properties
| Name | Description |
|---|---|
| Application |
Return the application that owns this service. |
| ApplicationContext |
Return the context of the single, global Application object of the current process. (Inherited from ContextWrapper) |
| ApplicationInfo |
Return the full application info for this context's package. (Inherited from ContextWrapper) |
| Assets |
Return an AssetManager instance for your application's package. (Inherited from ContextWrapper) |
| AttributionSource |
Gets the attribution source associated with this context. (Inherited from Context) |
| AttributionTag |
Attribution can be used in complex apps to logically separate parts of the app. (Inherited from Context) |
| BaseContext |
Gets the context to which this wrapper delegates its operations. (Inherited from ContextWrapper) |
| CacheDir |
Returns the absolute path to the application specific cache directory on the filesystem. (Inherited from ContextWrapper) |
| Class |
Returns the runtime class of this |
| ClassLoader |
Return a class loader you can use to retrieve classes in this package. (Inherited from ContextWrapper) |
| CodeCacheDir |
Returns the absolute path to the application specific cache directory on the filesystem designed for storing cached code. (Inherited from ContextWrapper) |
| ContentResolver |
Return a ContentResolver instance for your application's package. (Inherited from ContextWrapper) |
| DataDir |
Returns the absolute path to the directory on the filesystem where all private files belonging to this app are stored. (Inherited from ContextWrapper) |
| DeviceId |
Gets the device ID this context is associated with. (Inherited from Context) |
| Display |
Get the display this context is associated with. (Inherited from Context) |
| ExternalCacheDir |
Returns the absolute path to the directory on the primary external filesystem (that is somewhere on ExternalStorageDirectory where the application can place cache files it owns. (Inherited from ContextWrapper) |
| FilesDir |
Returns the absolute path to the directory on the filesystem where files created with OpenFileOutput(String, FileCreationMode) are stored. (Inherited from ContextWrapper) |
| ForegroundServiceType |
If the service has become a foreground service by calling
|
| Handle |
The handle to the underlying Android instance. (Inherited from Object) |
| IsDeviceProtectedStorage |
Indicates if the storage APIs of this Context are backed by device-protected storage. (Inherited from ContextWrapper) |
| IsRestricted |
Indicates whether this Context is restricted. (Inherited from Context) |
| IsUiContext |
Returns |
| JniIdentityHashCode |
Gets the identity hash code assigned to this Java peer by the interop runtime. (Inherited from Object) |
| JniManagedPeerState |
Gets the state flags last assigned by the runtime. (Inherited from JavaObject) |
| JniPeerMembers |
Provides JNI binding infrastructure for Android.App.Service. |
| MainExecutor |
Return an |
| MainLooper |
Return the Looper for the main thread of the current process. (Inherited from ContextWrapper) |
| NoBackupFilesDir |
Returns the absolute path to the directory on the filesystem similar to FilesDir. (Inherited from ContextWrapper) |
| ObbDir |
Return the primary external storage directory where this application's OBB files (if there are any) can be found. (Inherited from ContextWrapper) |
| OpPackageName |
Return the package name that should be used for |
| PackageCodePath |
Return the full path to this context's primary Android package. (Inherited from ContextWrapper) |
| PackageManager |
Return PackageManager instance to find global package information. (Inherited from ContextWrapper) |
| PackageName |
Return the name of this application's package. (Inherited from ContextWrapper) |
| PackageResourcePath |
Return the full path to this context's primary Android package. (Inherited from ContextWrapper) |
| Params |
Return the set of parameters which this Context was created with, if it
was created via |
| PeerReference |
Gets the JNI object reference for this Java peer. (Inherited from Object) |
| Resources |
Return a Resources instance for your application's package. (Inherited from ContextWrapper) |
| Theme |
Return the Theme object associated with this Context. (Inherited from ContextWrapper) |
| ThresholdClass |
Provides JNI binding infrastructure for Android.App.Service. |
| ThresholdType |
Provides JNI binding infrastructure for Android.App.Service. |
| UpdateableFlags |
Gets the list of bind flags that may be updated (i.e. added or removed) for an existing connection. (Inherited from Context) |
| Wallpaper |
Obsolete.
Gets the wallpaper drawable from the base context's legacy wallpaper API. (Inherited from ContextWrapper) |
| WallpaperDesiredMinimumHeight |
Obsolete.
Gets the desired minimum wallpaper height from the base context. (Inherited from ContextWrapper) |
| WallpaperDesiredMinimumWidth |
Obsolete.
Gets the desired minimum wallpaper width from the base context. (Inherited from ContextWrapper) |
Methods
| Name | Description |
|---|---|
| AttachBaseContext(Context) |
Set the base context for this ContextWrapper. (Inherited from ContextWrapper) |
| BindIsolatedService(Intent, Context+BindServiceFlags, String, IExecutor, IServiceConnection) |
See bindIsolatedService(Intent,int,String,Executor,ServiceConnection) Call BindServiceFlags.of(long) to obtain a BindServiceFlags object. (Inherited from Context) |
| BindIsolatedService(Intent, Int32, String, IExecutor, IServiceConnection) |
Variation of |
| BindService(Intent, Bind, IExecutor, IServiceConnection) |
Same as |
| BindService(Intent, Context+BindServiceFlags, IExecutor, IServiceConnection) |
See bindService(Intent,int,Executor,ServiceConnection) Call BindServiceFlags.of(long) to obtain a BindServiceFlags object. (Inherited from Context) |
| BindService(Intent, IServiceConnection, Bind) |
Connect to an application service, creating it if needed. (Inherited from ContextWrapper) |
| BindService(Intent, IServiceConnection, Context+BindServiceFlags) |
See bindService(Intent,ServiceConnection,int) Call BindServiceFlags.of(long) to obtain a BindServiceFlags object. (Inherited from Context) |
| BindServiceAsUser(Intent, IServiceConnection, Context+BindServiceFlags, UserHandle) |
See bindServiceAsUser(Intent,ServiceConnection,int,UserHandle) Call BindServiceFlags.of(long) to obtain a BindServiceFlags object. (Inherited from Context) |
| BindServiceAsUser(Intent, IServiceConnection, Int32, UserHandle) |
Binds to a service in the given |
| CheckCallingOrSelfPermission(String) |
Determine whether the calling process of an IPC or you have been granted a particular permission. (Inherited from ContextWrapper) |
| CheckCallingOrSelfUriPermission(Uri, ActivityFlags) |
Determine whether the calling process of an IPC or you has been granted permission to access a specific URI. (Inherited from ContextWrapper) |
| CheckCallingOrSelfUriPermissions(IList<Uri>, Int32) |
Determine whether the calling process of an IPC or you has been granted permission to access a list of URIs. (Inherited from Context) |
| CheckCallingPermission(String) |
Determine whether the calling process of an IPC you are handling has been granted a particular permission. (Inherited from ContextWrapper) |
| CheckCallingUriPermission(Uri, ActivityFlags) |
Determine whether the calling process and user ID has been granted permission to access a specific URI. (Inherited from ContextWrapper) |
| CheckCallingUriPermissions(IList<Uri>, Int32) |
Determine whether the calling process and uid has been granted permission to access a list of URIs. (Inherited from Context) |
| CheckContentUriPermissionFull(Uri, Int32, Int32, ActivityFlags) |
Determine whether a particular process and uid has been granted permission to access a specific content URI. (Inherited from Context) |
| CheckPermission(String, Int32, Int32) |
Determine whether the given permission is allowed for a particular process and user ID running in the system. (Inherited from ContextWrapper) |
| CheckSelfPermission(String) |
Determine whether you have been granted a particular permission. (Inherited from ContextWrapper) |
| CheckUriPermission(Uri, Int32, Int32, ActivityFlags) |
Determine whether a particular process and user ID has been granted permission to access a specific URI. (Inherited from ContextWrapper) |
| CheckUriPermission(Uri, String, String, Int32, Int32, ActivityFlags) |
Check both a Uri and normal permission. (Inherited from ContextWrapper) |
| CheckUriPermissions(IList<Uri>, Int32, Int32, Int32) |
Determine whether a particular process and uid has been granted permission to access a list of URIs. (Inherited from Context) |
| ClearWallpaper() |
Obsolete.
Delegates the legacy wallpaper-clear operation to the base context. (Inherited from ContextWrapper) |
| Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
| Construct(JniObjectReference, JniObjectReferenceOptions) |
Delegates construction of this peer to the runtime's value manager. (Inherited from JavaObject) |
| CreateAttributionContext(String) |
Return a new Context object for the current Context but attribute to a different tag. (Inherited from Context) |
| CreateConfigurationContext(Configuration) |
Return a new Context object for the current Context but whose resources are adjusted to match the given Configuration. (Inherited from ContextWrapper) |
| CreateContext(ContextParams) |
Creates a context with specific properties and behaviors. (Inherited from Context) |
| CreateContextForSplit(String) |
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. (Inherited from ContextWrapper) |
| CreateDeviceContext(Int32) |
Returns a new |
| CreateDeviceProtectedStorageContext() |
Return a new Context object for the current Context but whose storage APIs are backed by device-protected storage. (Inherited from ContextWrapper) |
| CreateDisplayContext(Display) |
Return a new Context object for the current Context but whose resources are adjusted to match the metrics of the given Display. (Inherited from ContextWrapper) |
| CreatePackageContext(String, PackageContextFlags) |
Return a new Context object for the given application name. (Inherited from ContextWrapper) |
| CreateWindowContext(Display, Int32, Bundle) |
Creates a |
| CreateWindowContext(Int32, Bundle) |
Creates a Context for a non-activity window. (Inherited from Context) |
| DatabaseList() |
Returns an array of strings naming the private databases associated with this Context's application package. (Inherited from ContextWrapper) |
| DeleteDatabase(String) |
Delete an existing private SQLiteDatabase associated with this Context's application package. (Inherited from ContextWrapper) |
| DeleteFile(String) |
Delete the given private file associated with this Context's application package. (Inherited from ContextWrapper) |
| DeleteSharedPreferences(String) |
Delete an existing shared preferences file. (Inherited from ContextWrapper) |
| Dispose() |
Releases the resources held by this Java peer. (Inherited from Object) |
| Dispose(Boolean) |
Releases the resources held by this Java peer. (Inherited from Object) |
| DisposeUnlessReferenced() |
Asks the value manager to dispose this peer unless its mapping retains this same managed instance. (Inherited from JavaObject) |
| Dump(FileDescriptor, PrintWriter, String[]) |
Print the Service's state into the given stream. |
| EnforceCallingOrSelfPermission(String, String) |
If neither you nor the calling process of an IPC you are handling has been granted a particular permission, throw a SecurityException. (Inherited from ContextWrapper) |
| EnforceCallingOrSelfUriPermission(Uri, ActivityFlags, String) |
If the calling process of an IPC or you has not been granted permission to access a specific URI, throw SecurityException. (Inherited from ContextWrapper) |
| EnforceCallingPermission(String, String) |
If the calling process of an IPC you are handling has not been granted a particular permission, throw a SecurityException. (Inherited from ContextWrapper) |
| EnforceCallingUriPermission(Uri, ActivityFlags, String) |
If the calling process and user ID has not been granted permission to access a specific URI, throw SecurityException. (Inherited from ContextWrapper) |
| EnforcePermission(String, Int32, Int32, String) |
If the given permission is not allowed for a particular process and user ID running in the system, throw a SecurityException. (Inherited from ContextWrapper) |
| EnforceUriPermission(Uri, Int32, Int32, ActivityFlags, String) |
If a particular process and user ID has not been granted permission to access a specific URI, throw SecurityException. (Inherited from ContextWrapper) |
| EnforceUriPermission(Uri, String, String, Int32, Int32, ActivityFlags, String) |
Enforce both a Uri and normal permission. (Inherited from ContextWrapper) |
| Equals(Object) |
Tests whether another managed peer refers to the same Java object. (Inherited from JavaObject) |
| Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
| FileList() |
Returns an array of strings naming the private files associated with this Context's application package. (Inherited from ContextWrapper) |
| GetColor(Int32) |
Returns a color associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
| GetColorStateList(Int32) |
Returns a color state list associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
| GetDatabasePath(String) |
Returns the absolute path on the filesystem where a database created with openOrCreateDatabase(String, int, CursorFactory) 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. (Inherited from ContextWrapper) |
| GetDir(String, FileCreationMode) |
Retrieve, creating if needed, a new directory in which the application can place its own custom data files. (Inherited from ContextWrapper) |
| GetDrawable(Int32) |
Returns a drawable object associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
| GetExternalCacheDirs() |
Returns absolute paths to application-specific directories on all external storage devices where the application can place cache files it owns. (Inherited from ContextWrapper) |
| GetExternalFilesDir(String) |
Returns the absolute path to the directory on the primary external filesystem (that is somewhere on ExternalStorageDirectory) where the application can place persistent files it owns. (Inherited from ContextWrapper) |
| GetExternalFilesDirs(String) |
Returns absolute paths to application-specific directories on all external storage devices where the application can place persistent files it owns. (Inherited from ContextWrapper) |
| GetExternalMediaDirs() |
Obsolete.
Returns absolute paths to application-specific directories on all external storage devices where the application can place media files. (Inherited from ContextWrapper) |
| GetFileStreamPath(String) |
Returns the absolute path on the filesystem where a file created with OpenFileOutput(String, FileCreationMode) is stored. (Inherited from ContextWrapper) |
| GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
| GetObbDirs() |
Returns absolute paths to application-specific directories on all external storage devices where the application's OBB files (if there are any) can be found. (Inherited from ContextWrapper) |
| GetSharedPreferences(String, FileCreationMode) |
Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values. (Inherited from ContextWrapper) |
| GetString(Int32, Object[]) |
Returns a localized string from the application's package's default string table. (Inherited from Context) |
| GetString(Int32) |
Returns a localized string from the application's package's default string table. (Inherited from Context) |
| GetSystemService(Class) |
Return the handle to a system-level service by class. (Inherited from Context) |
| GetSystemService(String) |
Return the handle to a system-level service by name. (Inherited from ContextWrapper) |
| GetSystemServiceName(Class) |
Gets the name of the system-level service that is represented by the specified class. (Inherited from ContextWrapper) |
| GetText(Int32) |
Return a localized, styled CharSequence from the application's package's default string table. (Inherited from Context) |
| GetTextFormatted(Int32) |
Return a localized, styled CharSequence from the application's package's default string table. (Inherited from Context) |
| GrantUriPermission(String, Uri, ActivityFlags) |
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. (Inherited from ContextWrapper) |
| JavaFinalize() |
Obsolete.
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
| MoveDatabaseFrom(Context, String) |
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. The database must be closed before being moved. (Inherited from ContextWrapper) |
| MoveSharedPreferencesFrom(Context, String) |
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. (Inherited from ContextWrapper) |
| Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
| NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
| ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
| ObtainStyledAttributes(IAttributeSet, Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
| ObtainStyledAttributes(Int32, Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
| ObtainStyledAttributes(Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
| OnBind(Intent) |
Return the communication channel to the service. |
| OnConfigurationChanged(Configuration) |
Called by the system when the device configuration changes while your component is running. |
| OnCreate() |
Called by the system when the service is first created. |
| OnDestroy() |
Called by the system to notify a Service that it is no longer used and is being removed. |
| OnLowMemory() |
This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. |
| OnRebind(Intent) |
Called when new clients have connected to the service, after it had
previously been notified that all had disconnected in its
|
| OnStart(Intent, Int32) |
Obsolete.
This method was deprecated in API level 15. |
| OnStartCommand(Intent, StartCommandFlags, Int32) |
Called by the system every time a client explicitly starts the service by calling
|
| OnTaskRemoved(Intent) |
This is called if the service is currently running and the user has removed a task that comes from the service's application. |
| OnTimeout(Int32, ForegroundService) |
Callback called when a particular foreground service type has timed out. |
| OnTimeout(Int32) |
Callback called on timeout for |
| OnTrimMemory(TrimMemory) |
Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. |
| OnUnbind(Intent) |
Called when all clients have disconnected from a particular interface published by the service. |
| OpenFileInput(String) |
Open a private file associated with this Context's application package for reading. (Inherited from ContextWrapper) |
| OpenFileOutput(String, FileCreationMode) |
Open a private file associated with this Context's application package for writing. (Inherited from ContextWrapper) |
| OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory, IDatabaseErrorHandler) |
Open a new private SQLiteDatabase associated with this Context's application package. (Inherited from ContextWrapper) |
| OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory) |
Open a new private SQLiteDatabase associated with this Context's application package. (Inherited from ContextWrapper) |
| PeekWallpaper() |
Obsolete.
Delegates the legacy wallpaper lookup to the base context's peek operation. (Inherited from ContextWrapper) |
| RebindService(IServiceConnection, Context+BindServiceFlags) |
Rebind an application service with updated bind service flags (Inherited from Context) |
| RegisterComponentCallbacks(IComponentCallbacks) |
Add a new |
| RegisterDeviceIdChangeListener(IExecutor, IIntConsumer) |
Adds a new device ID changed listener to the |
| RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags) |
Obsolete.
Register to receive intent broadcasts, with the receiver optionally being exposed to Instant Apps. See registerReceiver(BroadcastReceiver,IntentFilter) 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. See BroadcastReceiver for more information on Intent broadcasts. As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE , the system can place context-registered broadcasts in a queue while the app is in the cached state . 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 , receivers registered with this method will correctly respect the Intent.setPackage(String) 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. (Inherited from ContextWrapper) |
| RegisterReceiver(BroadcastReceiver, IntentFilter, ReceiverFlags) |
Register to receive intent broadcasts, with the receiver optionally being exposed to Instant Apps. See registerReceiver(BroadcastReceiver,IntentFilter) 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. See BroadcastReceiver for more information on Intent broadcasts. As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE , the system can place context-registered broadcasts in a queue while the app is in the cached state . 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 , receivers registered with this method will correctly respect the Intent.setPackage(String) 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. (Inherited from Context) |
| RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ActivityFlags) |
Obsolete.
Register to receive intent broadcasts, to run in the context of scheduler . See registerReceiver(BroadcastReceiver,IntentFilter,int) and registerReceiver(BroadcastReceiver,IntentFilter,String,Handler) for more information. See BroadcastReceiver for more information on Intent broadcasts. As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE , the system can place context-registered broadcasts in a queue while the app is in the cached state . 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 , receivers registered with this method will correctly respect the Intent.setPackage(String) 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. (Inherited from ContextWrapper) |
| RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ReceiverFlags) |
Register to receive intent broadcasts, to run in the context of scheduler . See registerReceiver(BroadcastReceiver,IntentFilter,int) and registerReceiver(BroadcastReceiver,IntentFilter,String,Handler) for more information. See BroadcastReceiver for more information on Intent broadcasts. As of Build.VERSION_CODES.UPSIDE_DOWN_CAKE , the system can place context-registered broadcasts in a queue while the app is in the cached state . 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 , receivers registered with this method will correctly respect the Intent.setPackage(String) 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. (Inherited from Context) |
| RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Register to receive intent broadcasts, to run in the context of <var>scheduler</var>. (Inherited from ContextWrapper) |
| RegisterReceiver(BroadcastReceiver, IntentFilter) |
Register a BroadcastReceiver to be run in the main activity thread. (Inherited from ContextWrapper) |
| RemoveStickyBroadcast(Intent) |
Obsolete.
Delegates removal of the retained sticky broadcast to the base context. (Inherited from ContextWrapper) |
| RemoveStickyBroadcastAsUser(Intent, UserHandle) |
Obsolete.
Delegates removal of the specified user's sticky broadcast to the base context. (Inherited from ContextWrapper) |
| RevokeSelfPermissionOnKill(String) |
Triggers the asynchronous revocation of a runtime permission. (Inherited from Context) |
| RevokeSelfPermissionsOnKill(ICollection<String>) |
Triggers the revocation of one or more permissions for the calling package. (Inherited from Context) |
| RevokeUriPermission(String, Uri, ActivityFlags) |
Remove permissions to access a particular content provider Uri that were previously added with grantUriPermission(String, Uri, int) 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. Unlike revokeUriPermission(Uri,int) , this method will only revoke permissions that had been explicitly granted through grantUriPermission(String, Uri, int) and only for the package specified. Any matching grants that have happened through other mechanisms (clipboard, activity launching, service starting, etc) will not be removed. (Inherited from ContextWrapper) |
| RevokeUriPermission(Uri, ActivityFlags) |
Remove all permissions to access a particular content provider Uri that were previously added with M:Android.Content.Context.GrantUriPermission(System.String,Android.Net.Uri,Android.Net.Uri). (Inherited from ContextWrapper) |
| SendBroadcast(Intent, String, Bundle) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an optional required permission to be enforced. (Inherited from Context) |
| SendBroadcast(Intent, String) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an optional required permission to be enforced. (Inherited from ContextWrapper) |
| SendBroadcast(Intent) |
Broadcast the given intent to all interested BroadcastReceivers. (Inherited from ContextWrapper) |
| SendBroadcastAsUser(Intent, UserHandle, String) |
Version of SendBroadcast(Intent, String) that allows you to specify the user the broadcast will be sent to. (Inherited from ContextWrapper) |
| SendBroadcastAsUser(Intent, UserHandle) |
Version of SendBroadcast(Intent) that allows you to specify the user the broadcast will be sent to. (Inherited from ContextWrapper) |
| SendBroadcastWithMultiplePermissions(Intent, String[]) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an array of required permissions to be enforced. (Inherited from Context) |
| SendOrderedBroadcast(Intent, Int32, String, String, BroadcastReceiver, Handler, String, Bundle, Bundle) |
Broadcasts an intent to interested receivers in order. (Inherited from ContextWrapper) |
| SendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of SendBroadcast(Intent) that allows you to receive data back from the broadcast. (Inherited from ContextWrapper) |
| SendOrderedBroadcast(Intent, String, Bundle, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of |
| SendOrderedBroadcast(Intent, String, Bundle) |
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. (Inherited from Context) |
| SendOrderedBroadcast(Intent, String, String, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of
|
| SendOrderedBroadcast(Intent, String) |
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. See BroadcastReceiver for more information on Intent broadcasts. (Inherited from ContextWrapper) |
| SendOrderedBroadcastAsUser(Intent, UserHandle, String, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of sendOrderedBroadcast(Intent,String,BroadcastReceiver,Handler,int,String,Bundle) 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. See BroadcastReceiver for more information on Intent broadcasts. Requires android.Manifest.permission.INTERACT_ACROSS_USERS (Inherited from ContextWrapper) |
| SendStickyBroadcast(Intent, Bundle) |
Perform a |
| SendStickyBroadcast(Intent) |
Obsolete.
Perform a |
| SendStickyBroadcastAsUser(Intent, UserHandle) |
Obsolete.
Delegates the sticky broadcast for the specified user to the base context. (Inherited from ContextWrapper) |
| SendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, Result, String, Bundle) |
Obsolete.
Delegates an ordered sticky broadcast and its result-callback arguments to the base context. (Inherited from ContextWrapper) |
| SendStickyOrderedBroadcastAsUser(Intent, UserHandle, BroadcastReceiver, Handler, Result, String, Bundle) |
Obsolete.
Delegates an ordered sticky broadcast for the specified user to the base context. (Inherited from ContextWrapper) |
| SetForeground(Boolean) |
This member is deprecated. |
| SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
| SetPeerReference(JniObjectReference, JniObjectReferenceOptions) |
Stores a reference value in the control block without creating a JNI reference copy. (Inherited from JavaObject) |
| SetTheme(Int32) |
Set the base theme for this context. (Inherited from ContextWrapper) |
| SetWallpaper(Bitmap) |
Obsolete.
Passes the bitmap to the base context's legacy wallpaper setter. (Inherited from ContextWrapper) |
| SetWallpaper(Stream) |
Obsolete.
Passes the input stream to the base context's legacy wallpaper setter. (Inherited from ContextWrapper) |
| ShouldShowRequestPermissionRationale(String) |
Gets whether you should show UI with rationale before requesting a permission. (Inherited from Context) |
| StartActivities(Intent[], Bundle) |
Launch multiple new activities. (Inherited from ContextWrapper) |
| StartActivities(Intent[]) |
Same as StartActivities(Intent[], Bundle) with no options specified. (Inherited from ContextWrapper) |
| StartActivity(Intent, Bundle) |
Launch a new activity. (Inherited from ContextWrapper) |
| StartActivity(Intent) |
Same as StartActivity(Intent, Bundle) with no options specified. (Inherited from ContextWrapper) |
| StartActivity(Type) |
Creates an explicit intent for the specified activity type and starts that activity. (Inherited from Context) |
| StartForeground(Int32, Notification, ForegroundService) |
An overloaded version of |
| StartForeground(Int32, Notification) |
If your service is started (running through |
| StartForegroundService(Intent) |
Similar to startService(Intent) , but with an implicit promise that the Service will call startForeground(int, android.app.Notification) 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 or later. On older Android versions, an internal exception RemoteServiceException is logged instead, with a corresponding message. Unlike the ordinary startService(Intent) , this method can be used at any time, regardless of whether the app hosting the service is in a foreground state. Note: Beginning with SDK Version Build.VERSION_CODES.S , apps targeting SDK Version Build.VERSION_CODES.S or higher are not allowed to start foreground services from the background. See Behavior changes: Apps targeting Android 12 for more details. (Inherited from ContextWrapper) |
| StartInstrumentation(ComponentName, String, Bundle) |
Start executing an Instrumentation class. (Inherited from ContextWrapper) |
| StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32, Bundle) |
Like StartActivity(Intent, Bundle), but taking a IntentSender to start. (Inherited from ContextWrapper) |
| StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32) |
Same as startIntentSender(IntentSender,Intent,int,int,int,Bundle) with no options specified. (Inherited from ContextWrapper) |
| StartService(Intent) |
Request that a given application service be started. (Inherited from ContextWrapper) |
| StopForeground(Boolean) |
Legacy version of |
| StopForeground(StopForegroundFlags) |
Remove this service from foreground state, allowing it to be killed if more memory is needed. |
| StopSelf() |
Stop the service, if it was previously started. |
| StopSelf(Int32) |
Old version of |
| StopSelfResult(Int32) |
Stop the service if the most recent time it was started was startId. |
| StopService(Intent) |
Request that a given application service be stopped. (Inherited from ContextWrapper) |
| ToArray<T>() |
Creates a managed array from this Java array wrapper. (Inherited from Object) |
| ToString() |
Returns a string representation of the object. (Inherited from Object) |
| UnbindService(IServiceConnection) |
Disconnect from an application service. (Inherited from ContextWrapper) |
| UnregisterComponentCallbacks(IComponentCallbacks) |
Remove a |
| UnregisterDeviceIdChangeListener(IIntConsumer) |
Removes a device ID changed listener from the Context. (Inherited from Context) |
| UnregisterFromRuntime() |
Unregisters this Java peer from the interop runtime. (Inherited from Object) |
| UnregisterReceiver(BroadcastReceiver) |
Unregister a previously registered BroadcastReceiver. (Inherited from ContextWrapper) |
| UpdateServiceBindings(ICollection<Context.UpdateBindingParams>) |
Perform a batch update of existing bindings. (Inherited from Context) |
| UpdateServiceGroup(IServiceConnection, Int32, Int32) |
For a service previously bound with |
| Wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. (Inherited from Object) |
| Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. (Inherited from Object) |
| Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IJavaPeerable.Disposed() |
Marks this peer as disposed and calls |
| IJavaPeerable.Finalized() |
Marks this peer as disposed and calls |
| IJavaPeerable.JniObjectReferenceControlBlock |
Gets the native control-block pointer used by this peer. (Inherited from JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
Stores the identity hash code supplied by the runtime. (Inherited from JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
Replaces the stored managed peer state flags. (Inherited from JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
Updates the peer reference and releases a disposed peer's control block when the reference is invalid. (Inherited from JavaObject) |
| IJavaPeerable.UnregisterFromRuntime() |
Removes this instance from the runtime's Java object lookup. |
Extension Methods
| Name | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
| JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
| JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
| JavaCast<TResult>(IJavaObject) |
Reuses a compatible managed peer or obtains a wrapper of the requested type. |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |