ConditionProviderService


public abstract class ConditionProviderService
extends Service

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


This class was deprecated in API level 29.
Instead of using an automatically bound service, use android.app.NotificationManager.setAutomaticZenRuleState(String,Condition) to tell the system about the state of your rule. In order to maintain a link from Settings to your rule configuration screens, provide a configuration activity that handles NotificationManager.ACTION_AUTOMATIC_ZEN_RULE on your AutomaticZenRule via android.app.AutomaticZenRule.setConfigurationActivity(ComponentName).

A service that provides conditions about boolean state.

To extend this class, you must declare the service in your manifest file with the Manifest.permission.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 Manifest.permission.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>

Condition providers cannot be bound by the system on low ram devices running Android Q (and below)

Summary

Constants

String EXTRA_RULE_ID

This constant is deprecated. see NotificationManager.EXTRA_AUTOMATIC_RULE_ID.

String META_DATA_CONFIGURATION_ACTIVITY

This constant is deprecated. see NotificationManager.ACTION_AUTOMATIC_ZEN_RULE.

String META_DATA_RULE_INSTANCE_LIMIT

This constant is deprecated. see NotificationManager.META_DATA_RULE_INSTANCE_LIMIT.

String META_DATA_RULE_TYPE

This constant is deprecated. see NotificationManager.META_DATA_AUTOMATIC_RULE_TYPE.

String SERVICE_INTERFACE

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

Inherited constants

Public constructors

ConditionProviderService()

Public methods

final void notifyCondition(Condition condition)

This method is deprecated. see android.app.NotificationManager.setAutomaticZenRuleState(String,Condition).

final void notifyConditions(Condition... conditions)

This method is deprecated. see android.app.NotificationManager.setAutomaticZenRuleState(String,Condition).

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.

static final void requestRebind(ComponentName componentName)

Request that the provider be rebound, after a previous call to (@link #requestUnbind).

final void requestUnbind()

Request that the provider service be unbound.

Inherited methods