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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -