added in API level 21

MediaProjectionManager

public final class MediaProjectionManager
extends Object

java.lang.Object
   ↳ android.media.projection.MediaProjectionManager


Manages the retrieval of certain types of MediaProjection tokens.

Instances of this class must be obtained using Context.getSystemService(Class) with the argument MediaProjectionManager.class or Context.getSystemService(String) with the argument Context.MEDIA_PROJECTION_SERVICE.

Summary

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 methods

createScreenCaptureIntent

added in API level 21
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

getMediaProjection

added in API level 21
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.

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 must never be null.

Returns
MediaProjection