android - PutLong on a null Long in argument Bundle -


given new instance method of fragment:

public static myfragment newinstance(long somelong) {     bundle args = new bundle();     myfragment fragment = new workoutdetailsroutineinfofragment();     args.putlong(args_long, somelong);     fragment.setarguments(args);     return fragment; } 

if somelong null, doesn't work.

caused by: java.lang.nullpointerexception: attempt invoke virtual method 'long java.lang.long.longvalue()' on null object reference

how store long if it's null?

check if null , if null add -1 if not null add long object. pretty easy


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

python - matplotlib equivalent for Ubuntu servers with no GUI? -