# Print output for @column tags ?>
public
final
class
MediaProjectionManager
extends Object
java.lang.Object | |
↳ | android.media.projection.MediaProjectionManager |
Manages the retrieval of certain types of MediaProjection
tokens.
Public methods | |
---|---|
Intent
|
createScreenCaptureIntent()
Returns an Intent that must be passed to startActivityForResult() in order to start screen capture. |
MediaProjection
|
getMediaProjection(int resultCode, Intent resultData)
Retrieve the MediaProjection obtained from a succesful screen capture request. |
Inherited methods | |
---|---|
public Intent createScreenCaptureIntent ()
Returns an Intent that must be passed to startActivityForResult() in order to start screen capture. The activity will prompt the user whether to allow screen capture. The result of this activity should be passed to getMediaProjection.
Returns | |
---|---|
Intent |
public MediaProjection getMediaProjection (int resultCode, Intent resultData)
Retrieve the MediaProjection obtained from a succesful screen
capture request. Will be null if the result from the
startActivityForResult() is anything other than RESULT_OK.
Starting from Android Build.VERSION_CODES.R
, if your application requests
the Manifest.permission.SYSTEM_ALERT_WINDOW
permission, and the
user has not explicitly denied it, the permission will be automatically granted until the
projection is stopped. This allows for user controls to be displayed on top of the screen
being captured.
Apps targeting SDK version Build.VERSION_CODES.Q
or later should specify
the foreground service type using the attribute R.attr.foregroundServiceType
in the service element of the app's manifest file.
The ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
attribute
should be specified.
Parameters | |
---|---|
resultCode |
int : The result code from Activity.onActivityResult(int, int, android.content.Intent) |
resultData |
Intent : The resulting data from Activity.onActivityResult(int, int, android.content.Intent)
This value cannot be null . |
Returns | |
---|---|
MediaProjection |
Throws | |
---|---|
IllegalStateException |
on pre-Q devices if a previously gotten MediaProjection
from the same resultData has not yet been stopped |
See also: