I am trying to get View converted in bitmap. In emulator my program is working fine and running as expected but when I run the same code in Device it gives null pointer Exception at particular line :
Bitmap b = Bitmap.createBitmap(view.getDrawingCache());
where view is object of RelativeLayout having Layout of current Activity. Can someone guide how can I resolve this issue. Thanks.
You need to call measure and layout on your view before using getDrawingCache(). Otherwise it will return null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With