Added in API level 29

StatusBarManager

open class StatusBarManager
kotlin.Any
   ↳ android.app.StatusBarManager

Allows an app to control the status bar.

Summary

Constants
static Int

Indicates that the requesting application is not in the foreground.

static Int

Indicates that the component does not match an enabled exported android.service.quicksettings.TileService for the current user.

static Int

Indicates that this package does not match that of the android.service.quicksettings.TileService.

static Int

Indicates that the user is not the current user.

static Int

The request could not be processed because no fulfilling service was found.

static Int

Indicates that there's a request in progress for this package.

static Int

Response indicating that the tile was added.

static Int

Response indicating that the tile was already added and the user was not prompted.

static Int

Response indicating that the tile was not added.

Public methods
open Boolean

Checks whether the supplied activity can Activity#startActivityForResult(Intent, int) a system activity that captures content on the screen to take a screenshot.

open Unit
requestAddTileService(tileServiceComponentName: ComponentName, tileLabel: CharSequence, icon: Icon, resultExecutor: Executor, resultCallback: Consumer<Int!>)

Request to the user to add a android.service.quicksettings.TileService to the set of current QS tiles.

Constants

TILE_ADD_REQUEST_ERROR_APP_NOT_IN_FOREGROUND

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_APP_NOT_IN_FOREGROUND: Int

Indicates that the requesting application is not in the foreground.

Value: 1004

TILE_ADD_REQUEST_ERROR_BAD_COMPONENT

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_BAD_COMPONENT: Int

Indicates that the component does not match an enabled exported android.service.quicksettings.TileService for the current user.

Value: 1002

TILE_ADD_REQUEST_ERROR_MISMATCHED_PACKAGE

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_MISMATCHED_PACKAGE: Int

Indicates that this package does not match that of the android.service.quicksettings.TileService.

Value: 1000

TILE_ADD_REQUEST_ERROR_NOT_CURRENT_USER

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_NOT_CURRENT_USER: Int

Indicates that the user is not the current user.

Value: 1003

TILE_ADD_REQUEST_ERROR_NO_STATUS_BAR_SERVICE

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_NO_STATUS_BAR_SERVICE: Int

The request could not be processed because no fulfilling service was found. This could be a temporary issue (for example, SystemUI has crashed).

Value: 1005

TILE_ADD_REQUEST_ERROR_REQUEST_IN_PROGRESS

Added in API level 33
static val TILE_ADD_REQUEST_ERROR_REQUEST_IN_PROGRESS: Int

Indicates that there's a request in progress for this package.

Value: 1001

TILE_ADD_REQUEST_RESULT_TILE_ADDED

Added in API level 33
static val TILE_ADD_REQUEST_RESULT_TILE_ADDED: Int

Response indicating that the tile was added.

Value: 2

TILE_ADD_REQUEST_RESULT_TILE_ALREADY_ADDED

Added in API level 33
static val TILE_ADD_REQUEST_RESULT_TILE_ALREADY_ADDED: Int

Response indicating that the tile was already added and the user was not prompted.

Value: 1

TILE_ADD_REQUEST_RESULT_TILE_NOT_ADDED

Added in API level 33
static val TILE_ADD_REQUEST_RESULT_TILE_NOT_ADDED: Int

Response indicating that the tile was not added.

Value: 0

Public methods

canLaunchCaptureContentActivityForNote

Added in API level 34
open fun canLaunchCaptureContentActivityForNote(activity: Activity): Boolean

Checks whether the supplied activity can Activity#startActivityForResult(Intent, int) a system activity that captures content on the screen to take a screenshot.

Note: The result should not be cached.

The system activity displays an editing tool that allows user to edit the screenshot, save it on device, and return the edited screenshot as android.net.Uri to the calling activity. User interaction is required to return the edited screenshot to the calling activity.

When true, callers can use Activity#startActivityForResult(Intent, int) to start start the content capture activity using Intent#ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE.
Requires android.Manifest.permission#LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE

Parameters
activity Activity: Calling activity This value cannot be null.
Return
Boolean true if the activity supports launching the capture content activity for note.

requestAddTileService

Added in API level 33
open fun requestAddTileService(
    tileServiceComponentName: ComponentName,
    tileLabel: CharSequence,
    icon: Icon,
    resultExecutor: Executor,
    resultCallback: Consumer<Int!>
): Unit

Request to the user to add a android.service.quicksettings.TileService to the set of current QS tiles.

Calling this will prompt the user to decide whether they want to add the shown android.service.quicksettings.TileService to their current tiles. The user can deny the request and the system can stop processing requests for a given ComponentName after a number of requests.

The request will show to the user information about the tile:

  • Application name
  • Label for the tile
  • Icon for the tile

The user for which this will be added is determined from the Context used to retrieve this service, and must match the current user. The requesting application must be in the foreground (ActivityManager.RunningAppProcessInfo#IMPORTANCE_FOREGROUND and the android.service.quicksettings.TileService must be exported. Note: the system can choose to auto-deny a request if the user has denied that specific request (user, ComponentName) enough times before.

Parameters
tileServiceComponentName ComponentName: ComponentName of the android.service.quicksettings.TileService for the request. This value cannot be null.
tileLabel CharSequence: label of the tile to show to the user. This value cannot be null.
icon Icon: icon to use in the tile shown to the user. This value cannot be null.
resultExecutor Executor: an executor to run the callback on This value cannot be null.
resultCallback Consumer<Int!>: callback to indicate the result of the request. This value cannot be null.