SettingsPreferenceService


public abstract class SettingsPreferenceService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.settings.preferences.SettingsPreferenceService


Base class for a service that exposes its settings preferences to external access.

This class is to be implemented by apps that contribute to the Android Settings surface. Access to this service is permission guarded by ERROR(/android.permission.READ_SYSTEM_PREFERENCES) for binding and reading, and guarded by both ERROR(/android.permission.READ_SYSTEM_PREFERENCES) and ERROR(/android.permission.WRITE_SYSTEM_PREFERENCES) for writing. An additional checks for access control are the responsibility of the implementing class.

This implementation must correspond to an exported service declaration in the host app AndroidManifest.xml as follows

 <service
     android:permission="android.permission.READ_SYSTEM_PREFERENCES"
     android:exported="true">
     <intent-filter>
         <action android:name="android.service.settings.preferences.action.PREFERENCE_SERVICE" />
     </intent-filter>
 </service>
 

Summary

Constants

String ACTION_PREFERENCE_SERVICE

Intent Action corresponding to a SettingsPreferenceService.

Inherited constants

Public constructors

SettingsPreferenceService()

Public methods

abstract void onGetAllPreferenceMetadata(MetadataRequest request, OutcomeReceiver<MetadataResultException> callback)

Retrieve the metadata for all exposed settings preferences within this application.

abstract void onGetPreferenceValue(GetValueRequest request, OutcomeReceiver<GetValueResultException> callback)

Retrieve the current value of the requested settings preference.

abstract void onSetPreferenceValue(SetValueRequest request, OutcomeReceiver<SetValueResultException> callback)

Set the value within the request to the target settings preference.

Inherited methods

Constants

ACTION_PREFERENCE_SERVICE

public static final String ACTION_PREFERENCE_SERVICE

Intent Action corresponding to a SettingsPreferenceService. Note that any checks for such services must be accompanied by a check to ensure the host is a system application. Given an ApplicationInfo you can check for ApplicationInfo.FLAG_SYSTEM, or when querying PackageManager.queryIntentServices you can provide the flag PackageManager.MATCH_SYSTEM_ONLY.

Constant Value: "android.service.settings.preferences.action.PREFERENCE_SERVICE"

Public constructors

SettingsPreferenceService

public SettingsPreferenceService ()

Public methods

onGetAllPreferenceMetadata

public abstract void onGetAllPreferenceMetadata (MetadataRequest request, 
                OutcomeReceiver<MetadataResultException> callback)

Retrieve the metadata for all exposed settings preferences within this application. This data should be a snapshot of their state at the time of this method being called.

Parameters
request MetadataRequest: object to specify request parameters

callback OutcomeReceiver: object to receive result or failure of request

onGetPreferenceValue

public abstract void onGetPreferenceValue (GetValueRequest request, 
                OutcomeReceiver<GetValueResultException> callback)

Retrieve the current value of the requested settings preference. If this value is not exposed or cannot be obtained for some reason, the corresponding result code will be set on the result object.

Parameters
request GetValueRequest: object to specify request parameters

callback OutcomeReceiver: object to receive result or failure of request

onSetPreferenceValue

public abstract void onSetPreferenceValue (SetValueRequest request, 
                OutcomeReceiver<SetValueResultException> callback)

Set the value within the request to the target settings preference. If this value cannot be written for some reason, the corresponding result code will be set on the result object.

Parameters
request SetValueRequest: object to specify request parameters

callback OutcomeReceiver: object to receive result or failure of request