是否可以在无根安卓手机中截屏.? [英] Is it possible to take screenshot in unrooted android phone.?

查看:53
本文介绍了是否可以在无根安卓手机中截屏.?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中单击该按钮有一个按钮,我想要android屏幕的屏幕截图,而不是我的手机没有root的应用程序屏幕.无root手机可以截图吗?

I am developing an application in which there is a button on click of that button i want the screenshot of android screen not that application screen my phone is unrooted. Is it possible to take screenshot of unrooted phone.?

推荐答案

是的,这是可能的.

查看 Android 屏幕截图库.

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

Android Screenshot Library (ASL) enables to programmatically capture screenshots from Android devices without requirement of having root access privileges. Instead, ASL utilizes a native service running in the background, started via the Android Debug Bridge (ADB) once per device boot.

如何实施?

修改清单 XML

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

In order for Android service to be accessible, add the following declaration to your client application's XML manifest:

<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) - 例如:

To obtain the IScreenshotProvider interface one must bind to the ASL service (pl.polidea.asl.ScreenshotService) using Context.bindService - for example:

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

参考资料

这篇关于是否可以在无根安卓手机中截屏.?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆