Here is the small question … Can we Authenticate two Beacon at single time to extract values from its sensor.
Yes, you should be able to simply instantiate two BeaconConnection objects and connect to two beacons at once.
Can you review it… I dnt know what is wrong in it. Here What i did,
- inside onCreate i put EstimoteSDK.initialize(…) ,
- then setRangingListener
- after that onBeaconsDiscovered(Region region, final List list)
- then i check for list is empty in if condition.
- Inside if condition i created new object as nearestBeacon = list.get(0);.
- after that int a = nearestBeacon.getMajor(); if (a == 39033) { //BeaconConnection code}
here 39033 is major value of my beacon.
Problem is BeaconConnection Code always shows error. I will send you the file.
Error shows
Error:(58, 38) error: no suitable constructor found for BeaconConnection(,Beacon,)
constructor BeaconConnection.BeaconConnection(Context,Beacon,ConnectionCallback) is not applicable
(argument mismatch; cannot be converted to Context)
constructor BeaconConnection.BeaconConnection(Context,String,ConnectionCallback) is not applicable
(argument mismatch; cannot be converted to Context)
MainActivity.zip (1.8 KB)
This line is the problem:
connection = new BeaconConnection(this, nearestBeacon1, ...
Because this code is inside the anonymous BeaconManager.RangingListener
class, this
here means the anonymous class (and thus you get the “argument mismatch; cannot be converted to Context” error). It should instead mean the MainActivity
class (which derives from Context
), so you need to make it MainActivity.this
.
(It’s a typical Java problem of accessing the outer class from the inner class. If you want to know more, here’s a StackOverflow thread about it.)
thanks for help…
I did that but i have one problem.
I just check the value inside “connection” which is “null” : connection = new BeaconConnection(this, nearestBeacon1, …
here connection is always null.
i just want to know i have to create a separate activity for BeaconConnection
i have created nearestBeacon1 as object for Beacon which contain all the details in the packet format from a beacon with specified major id (I use major value to filter the beacon).
i think i have to pass this object to another activity and initiate BeaconConnection. But i m uable to do so. Can you help me with it.