从另一个应用程序后台服务截图(编程) [英] Screenshot from background service of another application (programmatically)
问题描述
当我使用我要保存我访问该网站的截屏浏览器。因为有些网页在未来消失。所以,我决定做一个后台服务,将使该截图的时间定期,当我访问该网站说www.site.com。谁可以给我任何提示,链接到的教程,范例,...?
P.S。我的手机是植根。 Android 2.1系统。不要说这是不可能的:)
更新:
在无差JPG格式或HTML屏幕截图。哪一个更容易的方法来使。
过程SH =调用Runtime.getRuntime()EXEC(素,NULL,NULL);
OutputStream的OS = sh.getOutputStream();
os.write((/系统/斌/ screencap -p+/sdcard/img.png").getBytes("ASCII));
os.flush();
os.close();
sh.waitFor();
然后阅读img.png为位图和JPG转换如下
点阵屏= BitmapFactory.de codeFILE(Environment.getExternalStorageDirectory()+文件分割符+img.png);
//我的code保存
ByteArrayOutputStream字节=新ByteArrayOutputStream();
screen.com preSS(Bitmap.Com pressFormat.JPEG,15个字节);
//你可以创建一个新的文件名test.jpg放在SD卡中的文件夹。
文件F =新的文件(Environment.getExternalStorageDirectory()+文件分割符+test.jpg放在);
f.createNewFile();
//写在文件中的字节
FileOutputStream中FO =新的FileOutputStream(F);
fo.write(bytes.toByteArray());
//记得接近德FileOutput
fo.close();
When I use the browser I want to save screenshots of the site that I visited. Because some pages disappear in the future. So I decided to do a background service that would make the screenshots at regular intervals of time when I visit the site say www.site.com. Who can give me any tips, links to tutorials, examples, ...?
P.S. My phone is rooted. Android 2.1. and do not say that it is impossible :)
UPDATE:
Screenshots in JPG format or HTML without a difference. The method which is easier to make.
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();
这篇关于从另一个应用程序后台服务截图(编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!