android - NPE while using createBitmap -
i got npe line:
bitmap bm = bitmap.createbitmap(base64encodedecode.decodebase64(taskitems.get("task_image"))); logcat:
caused by: java.lang.nullpointerexception: attempt invoke virtual method 'int android.graphics.bitmap.getwidth()' on null object reference the problem taskitems.get("task_image") includes 4 spaces instead of decoded base64 string. how can check if base64 string correct string.
i tried like:
string taskimage = taskitems.get("task_image"); if (taskimage.trim().length() > 10) but, if there 200 of times 'a' token.
what can check if bitmap string bitmap string?
bm null, calling getwidth() on throws nullpointerexception. problem bitmap.createbitmap() returns null.
your npe comes line doing: "attempt invoke virtual method 'int android.graphics.bitmap.getwidth()' on null object reference".
check return value of bitmap.createbitmap(), base64encodedecode.decodebase64(), taskitems.get() avoid nulls.
you're doing 0 checks.
Comments
Post a Comment