I'm a newbie in android java programming, and I have a code to take a screenshot:
View content = findViewById(R.id.layoutroot); //it gives the "layoutroot cannot be resolved or is not a field" error
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File file = new File(Environment.getExternalStorageDirectory() + "/test.png");
try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
it gives the error:
"layoutroot cannot be resolved or is not a field"
I don't know if I have to define "layoutroot", just don't know! could anyone help me to solve this problem? thank you!