Methods Summary |
---|
public void | addCallback(android.media.projection.MediaProjectionManager$Callback callback, android.os.Handler handler)Add a callback to monitor all of the {@link MediaProjection}s activity.
Not for use by regular applications, must have the MANAGE_MEDIA_PROJECTION permission.
if (callback == null) {
throw new IllegalArgumentException("callback must not be null");
}
CallbackDelegate delegate = new CallbackDelegate(callback, handler);
mCallbacks.put(callback, delegate);
try {
mService.addCallback(delegate);
} catch (RemoteException e) {
Log.e(TAG, "Unable to add callbacks to MediaProjection service", e);
}
|
public android.content.Intent | createScreenCaptureIntent()Returns an Intent that must 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.
Intent i = new Intent();
i.setClassName("com.android.systemui",
"com.android.systemui.media.MediaProjectionPermissionActivity");
return i;
|
public MediaProjectionInfo | getActiveProjectionInfo()Get the {@link MediaProjectionInfo} for the active {@link MediaProjection}.
try {
return mService.getActiveProjectionInfo();
} catch (RemoteException e) {
Log.e(TAG, "Unable to get the active projection info", e);
}
return null;
|
public MediaProjection | getMediaProjection(int resultCode, android.content.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.
if (resultCode != Activity.RESULT_OK || resultData == null) {
return null;
}
IBinder projection = resultData.getIBinderExtra(EXTRA_MEDIA_PROJECTION);
if (projection == null) {
return null;
}
return new MediaProjection(mContext, IMediaProjection.Stub.asInterface(projection));
|
public void | removeCallback(android.media.projection.MediaProjectionManager$Callback callback)Remove a MediaProjection monitoring callback.
if (callback == null) {
throw new IllegalArgumentException("callback must not be null");
}
CallbackDelegate delegate = mCallbacks.remove(callback);
try {
if (delegate != null) {
mService.removeCallback(delegate);
}
} catch (RemoteException e) {
Log.e(TAG, "Unable to add callbacks to MediaProjection service", e);
}
|
public void | stopActiveProjection()Stop the current projection if there is one.
try {
mService.stopActiveProjection();
} catch (RemoteException e) {
Log.e(TAG, "Unable to stop the currently active media projection", e);
}
|