Intent setting = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
You can display the Android device information screen with the above code.
But when I run the code that captures the screen and saves the image, I get nothing.
I think this is for security reasons, but I need that feature. Is it possible in another way?
private void takeScreenshot(View v1) {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
This is the capture code I tried.
v1.setDrawingCacheEnabled(true);
put the above code
v1.getDrawingCache()
I don't get anything from the above code.
All actions should be performed automatically, without click events such as buttons.