是否可以在无根的Android手机中截取屏幕截图。?

时间:2015-09-17 05:16:50

标签: android screenshot

我正在开发一个应用程序,其中点击该按钮有一个按钮我想要Android屏幕的屏幕截图而不是该应用程序屏幕我的手机是无根的。是否可以拍摄无根电话的屏幕截图。

1 个答案:

答案 0 :(得分:3)

是的,这是可能的。

看看Android Screenshot Library

  

Android截图库(ASL)支持以编程方式从Android设备捕获屏幕截图,而无需具有root访问权限。相反,ASL利用在后台运行的本机服务,每次设备启动时通过Android调试桥(ADB)启动。

如何实施?

修改清单XML

为了能够访问Android服务,请将以下声明添加到客户端应用程序的XML清单中:

<service android:name="pl.polidea.asl.ScreenshotService">
    <intent-filter>
            <action android:name="pl.polidea.asl.ScreenshotService.BIND" />
            <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</service>

绑定服务

要获取IScreenshotProvider接口,必须使用Context.bindService绑定到ASL服务(pl.polidea.asl.ScreenshotService) - 例如:

// (using class name)
Intent intent = new Intent();
intent.setClass (this, pl.polidea.asl.ScreenshotService.class);
bindService (intent, aslServiceConnection, Context.BIND_AUTO_CREATE);

<强>参考