ContentSafetyManager
class ContentSafetyManager
| kotlin.Any | |
| ↳ | android.app.contentsafety.ContentSafetyManager |
The ContentSafetyManager provides access to content safety features.
It allows granted apps to manage content safety service configured on the device. Typical calling pattern will be to #checkContentRequest and #isFeatureEnabledRequest checkFile against sensitive content warnings.
Summary
| Constants | |
|---|---|
| static String |
Activity Action: Launch an activity showing information about restricted content. |
| static String |
Extra for |
| Public methods | |
|---|---|
| Intent? |
createContentRestrictedIntent(locusId: LocusId)Creates an |
| Boolean |
Returns whether content safety is currently enabled for the user. |
| Unit |
requestContentClassification(content: ClassifiableContent, executor: Executor, callback: ContentClassificationCallback)Requests classification of the specified content. |
Constants
ACTION_SHOW_RESTRICTED_CONTENT_DETAILS
static val ACTION_SHOW_RESTRICTED_CONTENT_DETAILS: String
Activity Action: Launch an activity showing information about restricted content.
Apps holding the android.app.role.RoleManager#ROLE_CONTENT_SAFETY must declare an activity that handles this action to show specific content restriction details.
Value: "android.app.contentsafety.action.SHOW_RESTRICTED_CONTENT_DETAILS"EXTRA_CONTENT_LOCUS_ID
static val EXTRA_CONTENT_LOCUS_ID: String
Extra for ACTION_SHOW_RESTRICTED_CONTENT_DETAILS containing the locus ID of the restricted content.
Value: "android.app.contentsafety.extra.CONTENT_LOCUS_ID"Public methods
createContentRestrictedIntent
fun createContentRestrictedIntent(locusId: LocusId): Intent?
Creates an Intent that can be used with Context.startActivity(Intent) to display a dialog about the restricted content.
| Parameters | |
|---|---|
locusId |
LocusId: the LocusId of the content to be restricted. This value cannot be null. |
| Return | |
|---|---|
Intent? |
the intent to display the restricted content dialog. This value may be null. |
isContentSafetyEnabled
fun isContentSafetyEnabled(): Boolean
Returns whether content safety is currently enabled for the user.
| Return | |
|---|---|
Boolean |
true if content safety is enabled for the user, false otherwise |
requestContentClassification
fun requestContentClassification(
content: ClassifiableContent,
executor: Executor,
callback: ContentClassificationCallback
): Unit
Requests classification of the specified content.
When content safety is enabled, this method determines if the specified content is appropriate based on the user's settings.
If the content is classified, the result provided to the callback will have a classification type of ContentClassificationResult.TYPE_ALLOWED, ContentClassificationResult.TYPE_WARNING, or ContentClassificationResult.TYPE_BLOCKED. If the content could not be classified or if content safety is disabled, the classification type will be ContentClassificationResult.TYPE_UNCLASSIFIED.
| Parameters | |
|---|---|
content |
ClassifiableContent: the content to be classified. This value cannot be null. |
executor |
Executor: the executor on which to run the callback. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
ContentClassificationCallback: the callback to receive the classification result. This value cannot be null. |