如何使用ScreenShotClient在我的Andr​​oid应用程序 [英] How to use ScreenShotClient in my android application

查看:2426
本文介绍了如何使用ScreenShotClient在我的Andr​​oid应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,它可以帮助用户捕捉到的android屏幕快照(安卓4.x版)。我知道,帧缓冲区在Android ICS打破。我听说,我们可以使用ScreenShotClient要做到这一点,如下。

I am developing an application which helps user to capture android screen shot (Android 4.x) . I know that framebuffer is broken on android ICS. I hear that we can use ScreenShotClient to do this as below.

ScreenshotClient screenshotClient = new ScreenshotClient();
screenshotClient->update();

不过,我有什么库导入使用它?它是可用下JNI code使用?

But, what library I have to import to use it? Is it available to use under jni code?

推荐答案

您所需要的库称为 libsurfaceflinger_client.so 。你可以从任何设备上运行姜饼<击>或更高 Android版本,使用命令将其

The library you need is called libsurfaceflinger_client.so. You can pull it from any device running Gingerbread or higher version of Android, with command

adb pull /system/lib/libsurfaceflinger_client.so

在ICS或JB,类 ScreenshotClient libgui.so 的一部分。在生成文件screencap这是一个使用的例子 ScreenshotClient ,表明连接器可能需要其他库:

On ICS or JB, class ScreenshotClient is part of libgui.so. The makefile for screencap which is the example of using ScreenshotClient, suggests that linker may need other libraries:

libcutils libutils libbinder libskia libui libgui

此外, screencap.cpp 的code的情况如下:

Also, the code of screencap.cpp goes as follows:

ScreenshotClient screenshot;
if (screenshot.update() == NO_ERROR) {
    base = screenshot.getPixels();
    w = screenshot.getWidth();
    h = screenshot.getHeight();
    f = screenshot.getFormat();
    size = screenshot.getSize();
} else {
    const char* fbpath = "/dev/graphics/fb0";
    int fb = open(fbpath, O_RDONLY);
    if (fb >= 0) {
        struct fb_var_screeninfo vinfo;
        if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) == 0) {
...

这意味着,至少你必须检查更新()取得成功。不幸的是,除非德设备植根,该应用程序不能被授予许可的/ dev /图形/ FB0阅读和使用 /系统的回退/斌/ screencap /系统/斌/截图

This means that at least you must check that update() succeed. Unfortunately, unless teh device is rooted, the apps cannot be granted permission to read from /dev/graphics/fb0 and use the fallback of /system/bin/screencap or /system/bin/screenshot.

这篇关于如何使用ScreenShotClient在我的Andr​​oid应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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