I'm trying to apply this code to get a screenshot of a view without an actionbar:
View main = findViewById(R.id.view);
Bitmap screenshot;
main.setDrawingCacheEnabled(true);
screenshot = Bitmap.createBitmap(main.getDrawingCache());
main.setDrawingCacheEnabled(false);
My question is how i can get the view if we don't have a layout,the view is set like:
setContentView(new MyView(this));
please take a look at this project: https://github.com/valerio-bozzolan/AcrylicPaint/blob/master/src/anupam/acrylic/EasyPaint.java Any help would be very appreciated!
UPDATE:
I got java.lang.NullPointerException at this line:
View v = new MyView(getBaseContext());
v.setDrawingCacheEnabled(true);
Bitmap cachedBitmap = v.getDrawingCache();
Bitmap copyBitmap = cachedBitmap.copy(Bitmap.Config.RGB_565, true); // <--- HERE
Happy new year!