I want to take a picture from my android app, but i'm getting a black image because of my videoView in current Activity. How can i take it without root access?
bellow is the code to get my current View:
In my main Activity:
saveBitmap(tackeScreenshot());
And the methods used:
public Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
public void saveBitmap(Bitmap bitmap) {
File imagePath = new File("/sdcard/image.png");
FileOutputStream fos;
try {
fos = new FileOutputStream(imagePath);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
Functions.Log("saveBitmap", e.getMessage());
} catch (IOException e) {
Functions.Log("saveBitmap", e.getMessage());
}
}