Beacon admin interface

I created the web admin interface for Beacon management wherein user can enter their Majorid & Minorid with respective information (metadata). Please have a look at the JSON

[{"name":"John","uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","majorid":"67889","minorid":"7032","notification":"Welcome","type":"Website","website":"estimote.com"}]

So, can i use parsing the data from JSON and send to the user if they enter the beacon region. Am i right?

I tried using parsing but i didn't get any metadata if i entered the beacon region.

Hey Raj -- I'm not sure I understand what's wrong. The way you code your backend and the communication between it and the device is entirely up to you, Estimote SDK doesn't interfere here. Is it beacon region monitoring not getting triggered?

we have 3 beacon with diff major & minor . So, i used manual value like below

region1 = new Region("region1", ESTIMOTEPROXIMITYUUID, 60518, 62835);

region2 = new Region("region2", ESTIMOTEPROXIMITYUUID, 7952, 42086);

region3 = new Region("region3", ESTIMOTE_PROXIMITY_UUID, 7632, 54047); 

Then in the monitoring region triggered i used below

beaconManager.setMonitoringListener(new MonitoringListener() {
@Override
public void onEnteredRegion(final Region region, List<Beacon> beacons) {

if (region.getIdentifier().equals("region1")) {

            notify_image.setImageResource(R.drawable.offer1);

}else if (region.getIdentifier().equals("region2")) {

notify_image.setImageResource(R.drawable.offer1);

}else if (region.getIdentifier().equals("region3")) {

notify_image.setImageResource(R.drawable.offer3);

}

Like above i used known values and its not dynamic....if i need to add or enter one more beacon region means i need to add manually..so i used webservice json values..im confusing to add region from json values..So please give some suggestion on this.

Hey raj—you should be able to simply iterate over your JSON array and create a set of beacon regions, which you can also store in some array.

You can read more about parsing JSON in Java here:
http://stackoverflow.com/questions/2591098/how-to-parse-json-in-java

Hi Piotr, I'm getting the JSON value from URL what i mentioned in the question. But how can i create the set of region for different beacons. Still confusing to create the region for different beacon, because beacon will add from server backend.

String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);

        Log.d("Response: ", "> " + jsonStr);

        if (jsonStr != null) {
            try {


                 JSONArray jarray = new JSONArray(jsonStr);                          

                  for (int i = 0; i < jarray.length(); i++) {


                        jObject = jarray.getJSONObject(i);

                        Log.d("jsonObj_Response: ", "> " + jObject);




                        String id = jObject.getString(TAG_UUID);

                        String major_id= jObject.getString(TAG_major_id);
                        String minor_id= jObject.getString(TAG_minor_id);
                        String gender = jObject.getString(TAG_notification);



                        // tmp hashmap for single contact
                        HashMap<String, String> contact = new HashMap<String, String>();

                        // adding each child node to HashMap key => value
                        contact.put(TAG_ID, id);

                        contact.put(TAG_major_id, major_id
                        contact.put(TAG_minor_id, minor_id

                        // adding contact to contact list
                        contactList.add(contact);

                        Log.d("jsonObj_Response: ", "> " + jObject);


                  } 

It seems you have a NullPointerException somewhere in your code:

10-29 00:15:10.684: E/AndroidRuntime(22444): Caused by: java.lang.NullPointerException
10-29 00:15:10.684: E/AndroidRuntime(22444): at com.estimote.examples.demos.NotifyDemoActivity$GetContacts.doInBackground(NotifyDemoActivity.java:376)

Sorry, i'm getting the majorid & minorid values from server and when pass to region it's checking only last value coming. How can i pass the array to region major & minorid and check all the values then match the major & minorid

[{"name":"Test","uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","majorid":"23695","minorid":"46901","notification":"","type":"Image","productimage":"myserver.com/beacon/staging/images/productimages/visualize2.png"},

{"name":"Test1","uuid":"B9407F30-F5F8-466E-AFF9-25556B57FE6D","majorid":"42583","minorid":"41770","notification":"","type":"Text","text_text":"<p>test</p>"}]

majorid= Integer.parseInt(jObject.getString("majorid")) ;

                     minor_id= Integer.parseInt(jObject.getString("minor_id")) ;

regionserver = new Region("regionserver", uuid, majorid, minorid); //creating region

public void onEnteredRegion(final Region region, List<Beacon> beacons) {

 if (region.getIdentifier().equals("region_server")) { 

           notify_image.setVisibility(View.VISIBLE);

}

If i have majorid & minorid

majorid: 23695 minorid=46901

majorid:42583 minorid:41170
It's checking last last major & minor_id values of 42583 & 41170 only