Screensaver

public final class Screensaver

Enable, disable, and configure the screensaver.

Not all methods are supported on all devices. If a method is not supported, it will throw UnsupportedOperationException. For example:

val screensaver = Screensaver(context)
try {
screensaver.gotoSleep()
// Supported on this device
} catch (e: UnsupportedOperationException) {
// Not supported on this device
}

Alternatively, you can check if the methods in this class are supported by inspecting supported.

All methods are blocking and should be invoked on a background thread.

Constructors

Link copied to clipboard
public Screensaver Screensaver(Context context)

Types

Link copied to clipboard

Properties

Link copied to clipboard

Get or set if dreams are enabled on battery power. If true, the device will allow the device to dream when on battery power.

Link copied to clipboard
private final Boolean supported

Convenience method to check if the methods in this class are supported on this device.

Link copied to clipboard
private final UnstableContentResolverClient unstableClient

Functions

Link copied to clipboard

Get the active dream components.

Link copied to clipboard
Link copied to clipboard

Get secure settings related to the screensaver.

Link copied to clipboard
public final Boolean getSupported()
Link copied to clipboard
public final UnstableContentResolverClient getUnstableClient()
Link copied to clipboard
public final Unit gotoSleep()

Forces the device to go to sleep.

Link copied to clipboard
public final Unit setDreamComponents(List<ComponentName> dreamComponents)

Set the active dream component.

Link copied to clipboard
public final Unit setDreamsEnabledOnBattery(Boolean dreamsEnabledOnBattery)
Link copied to clipboard

Set secure settings related to the screensaver.

Link copied to clipboard
public final Unit start()

Start the active dream component now. This does not lock the screen.