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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -