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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -