ContentSafetyAppService


abstract class ContentSafetyAppService : Service
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.app.Service
   ↳ android.service.contentsafety.ContentSafetyAppService

Base class for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

When the content safety subsystem is enabled and an app calls ContentSafetyManager.requestContentClassification, the system service will call onClassifyContent(ClassifiableContent).

<code>&lt;service android:name=".SampleContentSafetyAppService"
               android:permission="android.permission.BIND_CONTENT_SAFETY_SERVICE"
               android:privateComputeCore="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.app.action.CONTENT_SAFETY_SERVICE" /&gt;
          &lt;/intent-filter&gt;
       &lt;/service&gt;</code>

Summary

Constants
static String

Service action: Action for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

Inherited constants
Public constructors

Public methods
IBinder?
onBind(intent: Intent?)

Return the communication channel to the service.

abstract ContentClassificationResult

Called when content needs to be classified.

Inherited functions

Constants

ACTION_CONTENT_SAFETY_APP_SERVICE

static val ACTION_CONTENT_SAFETY_APP_SERVICE: String

Service action: Action for a service that the android.app.role.RoleManager.ROLE_CONTENT_SAFETY role holder must implement.

Value: "android.app.action.CONTENT_SAFETY_SERVICE"

Public constructors

ContentSafetyAppService

ContentSafetyAppService()

Public methods

onBind

fun onBind(intent: Intent?): IBinder?

Return the communication channel to the service. May return null if clients can not bind to the service. The returned android.os.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?: This value may be null.
Return
IBinder? This value may be null.

onClassifyContent

abstract fun onClassifyContent(content: ClassifiableContent): ContentClassificationResult

Called when content needs to be classified.

This is called on the main thread.

Parameters
content ClassifiableContent: the content to be classified.
This value cannot be null.
Return
ContentClassificationResult the content classification result.
This value cannot be null.