private org.altbeacon.beacon.Region getAltBeaconRegionFromWMRegion(Region region) { if (region != null) { Identifier id1 = null; Identifier id2 = null; Identifier id3 = null; if (region.getUuid() != null && !region.getUuid().isEmpty()) id1 = Identifier.parse(region.getUuid()); if (region.getMajor() != null && !region.getMajor().isEmpty()) id2 = Identifier.parse(region.getMajor()); if (region.getMinor() != null && !region.getMinor().isEmpty()) id3 = Identifier.parse(region.getMinor()); return new org.altbeacon.beacon.Region(region.getName(), id1, id2, id3); } else { return null; } }
public void onCreate() { super.onCreate(); BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this); // By default the AndroidBeaconLibrary will only find AltBeacons. If you wish to make it // find a different type of beacon, you must specify the byte layout for that beacon's // advertisement with a line like below. The example shows how to find a beacon with the // same byte layout as AltBeacon but with a beaconTypeCode of 0xaabb. To find the proper // layout expression for other beacon types, do a web search for "setBeaconLayout" // including the quotes. // // beaconManager.getBeaconParsers().add(new BeaconParser(). // setBeaconLayout("m:2-3=aabb,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25")); // beaconManager .getBeaconParsers() .add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); Log.d(TAG, "setting up background monitoring for beacons and power saving"); // wake up the app when a beacon is seen // Region region = new Region("backgroundRegion", null, null, null); ArrayList<Region> regionList = new ArrayList<Region>(); regionList.add( new Region( "1", Identifier.parse(getString(R.string.uuid)), Identifier.parse(getString(R.string.major)), Identifier.parse("1"))); regionList.add( new Region( "2", Identifier.parse(getString(R.string.uuid)), Identifier.parse(getString(R.string.major)), Identifier.parse("2"))); regionList.add( new Region( "3", Identifier.parse(getString(R.string.uuid)), Identifier.parse(getString(R.string.major)), Identifier.parse("3"))); regionBootstrap = new RegionBootstrap(this, regionList); // simply constructing this class and holding a reference to it in your custom Application // class will automatically cause the BeaconLibrary to save battery whenever the application // is not visible. This reduces bluetooth power usage by about 60% backgroundPowerSaver = new BackgroundPowerSaver(this); // If you wish to test beacon detection in the Android Emulator, you can use code like this: // BeaconManager.setBeaconSimulator(new TimedBeaconSimulator() ); // ((TimedBeaconSimulator) BeaconManager.getBeaconSimulator()).createTimedSimulatedBeacons(); }
@Override public void onCreate() { super.onCreate(); Parse.enableLocalDatastore(getApplicationContext()); // Add your initialization code here Parse.initialize( this, "3auP8OKsyBVdwDFFhQ7bAINSFldjA0zYrrSiKjIx", "FE0F9uUocCMzPiSyMl0UoEWDT1tdzYs3MOcQwp3O"); ParseUser.enableAutomaticUser(); ParseACL defaultACL = new ParseACL(); // If you would like all objects to be private by default, remove this line. defaultACL.setPublicReadAccess(true); ParseACL.setDefaultACL(defaultACL, true); // PushService.setDefaultPushCallback(this, MainActivity.class); ParseInstallation.getCurrentInstallation().saveInBackground(); ParseQuery<ParseObject> queryDrinks = new ParseQuery<>("ls_drinks"); queryDrinks.setLimit(200); queryDrinks.findInBackground( new FindCallback<ParseObject>() { public void done(final List<ParseObject> object, ParseException e) { // Remove the previously cached results. ParseObject.unpinAllInBackground( "ls_drinks", new DeleteCallback() { public void done(ParseException e) { // Cache the new results. ParseObject.pinAllInBackground("ls_drinks", object); } }); } }); ParseQuery<ParseObject> queryMenu = new ParseQuery<>("ls_menu"); // Locate the column named "day" in Parse.com and order list // by ascending queryMenu.findInBackground( new FindCallback<ParseObject>() { public void done(final List<ParseObject> object, ParseException e) { // Remove the previously cached results. ParseObject.unpinAllInBackground( "ls_menu", new DeleteCallback() { public void done(ParseException e) { // Cache the new results. ParseObject.pinAllInBackground("ls_menu", object); } }); } }); ParseQuery<ParseObject> queryReviews = new ParseQuery<>("ls_reviews"); // Locate the column named "day" in Parse.com and order list // by ascending queryReviews.findInBackground( new FindCallback<ParseObject>() { public void done(final List<ParseObject> object, ParseException e) { // Remove the previously cached results. ParseObject.unpinAllInBackground( "ls_reviews", new DeleteCallback() { public void done(ParseException e) { // Cache the new results. ParseObject.pinAllInBackground("ls_reviews", object); } }); } }); ParseQuery<ParseObject> queryGroups = new ParseQuery<>("ls_groups"); // Locate the column named "day" in Parse.com and order list // by ascending queryGroups.findInBackground( new FindCallback<ParseObject>() { public void done(final List<ParseObject> object, ParseException e) { // Remove the previously cached results. ParseObject.unpinAllInBackground( "ls_groups", new DeleteCallback() { public void done(ParseException e) { // Cache the new results. ParseObject.pinAllInBackground("ls_groups", object); } }); } }); Log.d(TAG, "App started up"); BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this); beaconManager .getBeaconParsers() .add( new BeaconParser() .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25")); String blueUUID = "b7d1027d-6788-416e-994f-ea11075f1765"; Region region = new Region("comapps.com.lakewoodsmokehouse", Identifier.parse(blueUUID), null, null); regionBootstrap = new RegionBootstrap(this, region); BeaconManager.setDebug(true); }