0

The first time i run the app after uninstalling & reinstalling sometimes it crashes due to

 viewHolder.setTimestamp(DateUtils.getRelativeTimeSpanString((long) model.getTimestamp()).toString());

giving an error

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference

what should i do to solve this issue as after crashing once the next time everything works fine.If you need more codes to guide me then just ask.

AL.
  • 36,815
  • 10
  • 142
  • 281
Shubhendra
  • 117
  • 1
  • 13

1 Answers1

-2

you can use it in try catch like this way.

try
{
viewHolder.setTimestamp(DateUtils.getRelativeTimeSpanString((long) model.getTimestamp()).toString());
}
catch(Exception e)
{
}
faisal iqbal
  • 724
  • 1
  • 8
  • 20