Most visited

Recently visited

Added in API level 24

ConditionProviderService

public abstract class ConditionProviderService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.notification.ConditionProviderService


A service that provides conditions about boolean state.

To extend this class, you must declare the service in your manifest file with the BIND_CONDITION_PROVIDER_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action. If you want users to be able to create and update conditions for this service to monitor, include the META_DATA_RULE_TYPE and META_DATA_CONFIGURATION_ACTIVITY tags and request the ACCESS_NOTIFICATION_POLICY permission. For example:

 <service android:name=".MyConditionProvider"
          android:label="@string/service_name"
          android:permission="android.permission.BIND_CONDITION_PROVIDER_SERVICE">
     <intent-filter>
         <action android:name="android.service.notification.ConditionProviderService" />
     </intent-filter>
     <meta-data
               android:name="android.service.zen.automatic.ruleType"
               android:value="@string/my_condition_rule">
           </meta-data>
           <meta-data
               android:name="android.service.zen.automatic.configurationActivity"
               android:value="com.my.package/.MyConditionConfigurationActivity">
           </meta-data>
 </service>

Summary

Constants

String EXTRA_RULE_ID

A String rule id extra passed to META_DATA_CONFIGURATION_ACTIVITY.

String META_DATA_CONFIGURATION_ACTIVITY

The name of the meta-data tag containing the ComponentName of an activity that allows users to configure the conditions provided by this service.

String META_DATA_RULE_INSTANCE_LIMIT

The name of the meta-data tag containing the maximum number of rule instances that can be created for this rule type.

String META_DATA_RULE_TYPE

The name of the meta-data tag containing a localized name of the type of zen rules provided by this service.

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

ConditionProviderService()

Public methods

final void notifyCondition(Condition condition)

Informs the notification manager that the state of a Condition has changed.

final void notifyConditions(Condition... conditions)

Informs the notification manager that the state of one or more Conditions has changed.

IBinder onBind(Intent intent)

Return the communication channel to the service.

abstract void onConnected()

Called when this service is connected.

void onRequestConditions(int relevance)
abstract void onSubscribe(Uri conditionId)

Called by the system when there is a new Condition to be managed by this provider.

abstract void onUnsubscribe(Uri conditionId)

Called by the system when a Condition has been deleted.

Inherited methods

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

EXTRA_RULE_ID

Added in API level 24
String EXTRA_RULE_ID

A String rule id extra passed to META_DATA_CONFIGURATION_ACTIVITY.

Constant Value: "android.service.notification.extra.RULE_ID"

META_DATA_CONFIGURATION_ACTIVITY

Added in API level 24
String META_DATA_CONFIGURATION_ACTIVITY

The name of the meta-data tag containing the ComponentName of an activity that allows users to configure the conditions provided by this service.

Constant Value: "android.service.zen.automatic.configurationActivity"

META_DATA_RULE_INSTANCE_LIMIT

Added in API level 24
String META_DATA_RULE_INSTANCE_LIMIT

The name of the meta-data tag containing the maximum number of rule instances that can be created for this rule type. Omit or enter a value <= 0 to allow unlimited instances.

Constant Value: "android.service.zen.automatic.ruleInstanceLimit"

META_DATA_RULE_TYPE

Added in API level 24
String META_DATA_RULE_TYPE

The name of the meta-data tag containing a localized name of the type of zen rules provided by this service.

Constant Value: "android.service.zen.automatic.ruleType"

SERVICE_INTERFACE

Added in API level 24
String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Constant Value: "android.service.notification.ConditionProviderService"

Public constructors

ConditionProviderService

Added in API level 24
ConditionProviderService ()

Public methods

notifyCondition

Added in API level 24
void notifyCondition (Condition condition)

Informs the notification manager that the state of a Condition has changed. Use this method to put the system into Do Not Disturb mode or request that it exits Do Not Disturb mode. This call will be ignored unless there is an enabled AutomaticZenRule owned by service that has an getConditionId() equal to this id.

Parameters
condition Condition: the condition that has changed.

notifyConditions

Added in API level 24
void notifyConditions (Condition... conditions)

Informs the notification manager that the state of one or more Conditions has changed. See notifyCondition(Condition) for restrictions.

Parameters
conditions Condition: the changed conditions.

onBind

Added in API level 24
IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
IBinder Return an IBinder through which clients can call on to the service.

onConnected

Added in API level 24
void onConnected ()

Called when this service is connected.

onRequestConditions

Added in API level 24
void onRequestConditions (int relevance)

Parameters
relevance int

onSubscribe

Added in API level 24
void onSubscribe (Uri conditionId)

Called by the system when there is a new Condition to be managed by this provider.

Parameters
conditionId Uri: the Uri describing the criteria of the condition.

onUnsubscribe

Added in API level 24
void onUnsubscribe (Uri conditionId)

Called by the system when a Condition has been deleted.

Parameters
conditionId Uri: the Uri describing the criteria of the deleted condition.

Hooray!