Skip to main content

Posts

Showing posts with the label screenshot

Android take screen shot programatically

First off i am writing a root app so root permissions are no issue. I've searched and searched and found a lot of code that never worked for me here is what i've pieced together so far and sorta works. When i say sorta i mean it makes an image on my /sdcard/test.png however the file is 0 bytes and obviously can't be viewed. public class ScreenShot extends Activity{ View content; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.blank); content = findViewById(R.id.blankview); getScreen(); } private void getScreen(){ Bitmap bitmap = content.getDrawingCache(); File file = new File("/sdcard/test.png"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.PNG, 100, ostream); ostream.close(); } catch (Exception e) { e.printStackTrace(); } } } Any h