Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 另一个应用程序后台服务的屏幕截图(以编程方式)_Android_Screenshot - Fatal编程技术网

Android 另一个应用程序后台服务的屏幕截图(以编程方式)

Android 另一个应用程序后台服务的屏幕截图(以编程方式),android,screenshot,Android,Screenshot,当我使用浏览器时,我想保存我访问过的网站的截图。因为有些页面将来会消失。所以我决定做一个后台服务,当我访问网站www.site.com时,它会定期制作屏幕截图。谁能给我任何提示、教程链接、示例等 还有,我的手机被扎根了。安卓2.1。不要说这是不可能的:) 更新: JPG格式或HTML格式的屏幕截图,没有区别。更容易制作的方法。 不需要扎根 需要扎根 最糟糕的情况是,您可以在通过USB插入的同时使用android SDK并拍摄屏幕截图。PNG/JPG或HTML屏幕截图?如果是前者,请使用UI

当我使用浏览器时,我想保存我访问过的网站的截图。因为有些页面将来会消失。所以我决定做一个后台服务,当我访问网站www.site.com时,它会定期制作屏幕截图。谁能给我任何提示、教程链接、示例等

还有,我的手机被扎根了。安卓2.1。不要说这是不可能的:)

更新:

JPG格式或HTML格式的屏幕截图,没有区别。更容易制作的方法。

  • 不需要扎根

  • 需要扎根


最糟糕的情况是,您可以在通过USB插入的同时使用android SDK并拍摄屏幕截图。

PNG/JPG或HTML屏幕截图?如果是前者,请使用UI线程中的PictureListener#onNewPicture(),然后将其发送到服务。如果要访问其他应用程序的屏幕截图,则需要root权限。我希望问题是这样的……那么非根手机呢?如果你是非根手机,你就不能截取其他应用的屏幕。只允许拍摄你的应用程序的屏幕截图。@ViswanathLekshmanan..使用
TimerTask
Service
是否有效,请确保你有root访问权限
TimerTask
只是另一个
线程
 Process sh = Runtime.getRuntime().exec("su", null,null);

                        OutputStream  os = sh.getOutputStream();
                        os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
                        os.flush();

                        os.close();
                        sh.waitFor();

    then read img.png as bitmap and convert it jpg as follows 

Bitmap screen = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+ File.separator +"img.png");

//my code for saving
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        screen.compress(Bitmap.CompressFormat.JPEG, 15, bytes);

//you can create a new file name "test.jpg" in sdcard folder.

File f = new File(Environment.getExternalStorageDirectory()+ File.separator + "test.jpg");
                f.createNewFile();
//write the bytes in file
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
// remember close de FileOutput

        fo.close();