java.lang.NullPointerException?

Out of sudden I’m getting fatal exception on this line.
beaconKey = String.format("%d:%d", beacon.getMajor(), beacon.getMinor())

Full code
public List<String> placesNearBeacon(Beacon beacon) { beaconKey = String.format("%d:%d", beacon.getMajor(), beacon.getMinor()); if (PLACES_BY_BEACONS.containsKey(beaconKey)) { return PLACES_BY_BEACONS.get(beaconKey); } return Collections.emptyList(); }

The error is
Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead

It works fine before I edited something in the code, undo the changes wont remove the bug somehow…

Hmm, can you paste the full code from your MainActivity to https://gist.github.com/, and then post the URL to that here?

Hi, thanks for offering to help again !

But today I tried on my friend’s android and it worked fine without any error.
Hours later and it worked on my android once again !
A friend of mine said that it could because of my android is rooted.
Note that, I did not edit anything in the code.

Do you still want me post the codes ? The error has changed anyway…I have no idea why and how

Well, if it works now then I guess it’s all good (:

The “locale” message I believe is just a warning, unrelated to beacons at all. The NullPointerException was more interesting.

1 Like