android - how to set different ids for different estimote beacons? -


suppose, android app detecting 3 beacons in range default uuid value. so, how can set/change name each beacons in anndroid (to identify each beacon)?

appreciations suggestions... thanks

first of need estimote sdk can create beacondetection service this

public class beaconmyservice extends service {     private static final string tag = "beaconmyservice";      private final handler handler = new handler();      private beaconmanager beaconmanager;      private static final region all_estimote_beacons_region = new region("rid", null, null, null);      @override     public int onstartcommand(intent intent, int flags, int startid)     {         if (beaconmanager.isbluetoothenabled())         {              connecttoservice();         }         return service.start_not_sticky;      }      private void connecttoservice()     {         beaconmanager.connect(new beaconmanager.servicereadycallback()         {             @override             public void onserviceready()             {                 try                 {                     beaconmanager.startranging(all_estimote_beacons_region);                 }                 catch (remoteexception e)                 {                     log.e("myservice", "cannot start ranging, terrible happened");                     log.e("", "cannot start ranging", e);                 }             }         });     }       @override     public void oncreate()     {         super.oncreate();          beaconmanager = new beaconmanager(this);         beaconmanager.setranginglistener(new beaconmanager.ranginglistener()         {              @override             public void onbeaconsdiscovered(region region, final list<beacon> beacons)             {                  // note beacons reported here sorted                 // estimated                 // distance between device , beacon.                 (int index = 0; index < beacons.size(); index++)                 {                     beacon beacon = beacons.get(index);                      if (beacon != null)                     {                         log.v("beacon macaddress", beacon.getmacaddress() + "");                         if (!constants.beaconsdetectedlist.containskey(beacon.getmacaddress()))                         {//constants.beaconsdetectedlist list of beacon mac addresses                     //public static hashmap<string, long> beaconsdetectedlist = new hashmap<string, long>();                          //to check if beacon detected first time                              if (constants.beacon1.equalsignorecase(beacon.getmacaddress()))                             {//constants.beacon1 mac address of beacon 1 assigned in constants                                 constants.beaconsdetectedlist.put(beacon.getmacaddress(), system.currenttimemillis());                                 handler.postdelayed(beacon1detection, 2000);                             }                             else if (constants.beacon2.equalsignorecase(beacon.getmacaddress()))                             {                                 constants.beaconsdetectedlist.put(beacon.getmacaddress(), system.currenttimemillis());                                 handler.postdelayed(beacon2detection, 2000);                             }                         }                         else                         {/*do nothing*/                         }                      }                 }              }         });      }      private runnable beacon1detection = new runnable()     {         public void run()         {              beacon1info();         }     };      private runnable beacon2detection = new runnable()     {         public void run()         {              beacon2info();         }     };      private void beacon1info()     {         intent intent = new intent(constants.beacon1broadcast_action);         sendbroadcast(intent);     }//in constants      //public static final string beacon1broadcast_action = "beacon1action";        private void beacon2info()     {         intent intent = new intent(constants.beacon2broadcast_action);         sendbroadcast(intent);     }// in constants     //public static final string beacon2broadcast_action = "beacon2action";      @override     public ibinder onbind(intent intent)     {         return null;     }      @override     public void ondestroy()     {         handler.removecallbacks(beacon1detection);         handler.removecallbacks(beacon2detection);         super.ondestroy();     } } 

and need beaconbroadcastreceiver receive broadcasts in service , open respective activity

public class beaconbroadcastreceiver extends broadcastreceiver {          @override         public void onreceive(context context, intent intent) {             if (intent.getaction().equals(constants.beacon1broadcast_action)) {                 intent intent2 = new intent(context, beacon1layout.class);                 context.startactivity(intent2);              } else if (intent.getaction().equals(constants.beacon2broadcast_action)) {                 intent intent2 = new intent(context, beacon2layout.class);                 context.startactivity(intent2);              }         }      } 

hope you, luck :)


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -