I have the follow code to get the screenshot
View screen = getWindow().getDecorView();
screen.setDrawingCacheEnabled(true);
screen.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
screen.buildDrawingCache();
Bitmap bitmap = screen.getDrawingCache();
The code is in onOptionsItemSelected
in UI thread.
It runs fine when I test it manually. However, when I run the app with monkey, bitmap
is null
I am not sure if it always null in monkey mode or just occasionally since monkey's randomness.
Any ideas that why monkey could behave differently? I do not want to blindly add a null pointer checker in later code.
Thanks