Hi!
Yesterday, my app worked perfectly. Today, when I open it to use it again, the app keeps crashing at this line (last line of the code):
// Defining the beacons to look out for //
private static final Map<String, List<String>> PLACES_BY_BEACONS;
// beacon defintion
private BeaconManager beaconManager;
private Region region;
// TODO: replace "<major>:<minor>" strings to match your own beacons.
static {
Map<String, List<String>> placesByBeacons = new HashMap<>();
placesByBeacons.put("56738:65449", new ArrayList<String>() {{ // beet
add("Beacon 1");
}});
placesByBeacons.put("61045:1044", new ArrayList<String>() {{ // pink
add("Beacon 2");
}});
PLACES_BY_BEACONS = Collections.unmodifiableMap(placesByBeacons);
}
private List<String> placesNearBeacon(Beacon beacon) {
String beaconKey = String.format("%d:%d", beacon.getMajor(), beacon.getMinor());
if (PLACES_BY_BEACONS.containsKey(beaconKey)) {
return PLACES_BY_BEACONS.get(beaconKey);
}
return Collections.emptyList();
}
/* ----------------------------------------------------------------------------------------------
oncreate
---------------------------------------------------------------------------------------------- */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
state_textview = (TextView) findViewById(R.id.state); // initialize textview
final Button startButton = (Button) findViewById(R.id.start); // initialize button
checkExternalMedia(); // check availability of sd card for reading and writing
verifyStoragePermissions(this); // check if storage permission has been given
/*
ACTIVITY */
beaconManager = new BeaconManager(this);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
if (!list.isEmpty()) { // upon discovery of beacons, do:
// indentify beacons
final Beacon beacon_0 = list.get(0);
final Beacon beacon_1 = list.get(1); // THIS LINE, IT KEEPS CRASHING THE APP
Anyone with any idea why? ):