1

To make screenshots I use this code:

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();

But this is veeery slow! Maybe because phone is saving this image on storage. To get this bitmap I use this code:

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

But that's pretty slow! Is possible to get bitmap but not save it? Maybe it will be much faster?

Gavin S. Yancey
  • 1,216
  • 1
  • 13
  • 34
kubaork
  • 161
  • 2
  • 12

1 Answers1

1

here you go View.getDrawingCache() returns the currently drawn View suface.

view.setsetDrawingCacheEnabled(true);
final Bitmap screenshot = view.getDrawingCache();
view.setDrawingCacheEnabled(false);    

//use bitmap
martyglaubitz
  • 992
  • 10
  • 21