Most visited

Recently visited

Added in API level 21

MediaProjection

public final class MediaProjection
extends Object

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


令牌应用程序能够捕捉屏幕内容和/或录制系统音频。 授予的确切功能取决于MediaProjection的类型。

屏幕捕获会话可以通过createScreenCaptureIntent()开始。 这赋予了捕捉屏幕内容但不捕获系统音频的能力。

Summary

Nested classes

class MediaProjection.Callback

预测会话的回调。

Public methods

VirtualDisplay createVirtualDisplay(String name, int width, int height, int dpi, int flags, Surface surface, VirtualDisplay.Callback callback, Handler handler)

创建一个 VirtualDisplay来捕获屏幕的内容。

void registerCallback(MediaProjection.Callback callback, Handler handler)

注册侦听器以接收有关 MediaProjection更改状态的通知。

void stop()

停止投影。

void unregisterCallback(MediaProjection.Callback callback)

取消注册MediaProjection侦听器。

Inherited methods

From class java.lang.Object

Public methods

createVirtualDisplay

Added in API level 21
VirtualDisplay createVirtualDisplay (String name, 
                int width, 
                int height, 
                int dpi, 
                int flags, 
                Surface surface, 
                VirtualDisplay.Callback callback, 
                Handler handler)

创建 VirtualDisplay以捕获屏幕的内容。

Parameters
name String: The name of the virtual display, must be non-empty.
width int: The width of the virtual display in pixels. Must be greater than 0.
height int: The height of the virtual display in pixels. Must be greater than 0.
dpi int: The density of the virtual display in dpi. Must be greater than 0.
flags int: A combination of virtual display flags. See DisplayManager for the full list of flags.
surface Surface: The surface to which the content of the virtual display should be rendered, or null if there is none initially.
callback VirtualDisplay.Callback: Callback to call when the virtual display's state changes, or null if none.
handler Handler: The Handler on which the callback should be invoked, or null if the callback should be invoked on the calling thread's main Looper.
Returns
VirtualDisplay

也可以看看:

registerCallback

Added in API level 21
void registerCallback (MediaProjection.Callback callback, 
                Handler handler)

注册侦听器以接收有关 MediaProjection更改状态的通知。

Parameters
callback MediaProjection.Callback: The callback to call.
handler Handler: The handler on which the callback should be invoked, or null if the callback should be invoked on the calling thread's looper.

也可以看看:

stop

Added in API level 21
void stop ()

停止投影。

unregisterCallback

Added in API level 21
void unregisterCallback (MediaProjection.Callback callback)

取消注册MediaProjection侦听器。

Parameters
callback MediaProjection.Callback: The callback to unregister.

也可以看看:

Hooray!