3

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.

2
  • Can you post the rest of your code so we can see what is going on? Thanks! Commented Aug 14, 2012 at 13:39
  • Can u plz share ur code? Commented Aug 14, 2012 at 13:39

1 Answer 1

1

You need to call measure and layout on your view before using getDrawingCache(). Otherwise it will return null.

Sign up to request clarification or add additional context in comments.

1 Comment

You can still get null even with measure and layout set. This problem remains unsolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.