本文整理汇总了Java中com.estimote.sdk.BeaconManager.setRangingListener方法的典型用法代码示例。如果您正苦于以下问题:Java BeaconManager.setRangingListener方法的具体用法?Java BeaconManager.setRangingListener怎么用?Java BeaconManager.setRangingListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.estimote.sdk.BeaconManager
的用法示例。
在下文中一共展示了BeaconManager.setRangingListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scan
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
public void scan(){
beaconManager = new BeaconManager(c);
//final RefreshingDialog dialog = new RefreshingDialog(c);
//dialog.createRefreshingDialog();
startScanning();
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
for(Beacon b : list){
addBeacon(b);
}
}
});
}
示例2: PiggateEstimoteBridge
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
public PiggateEstimoteBridge(Piggate piggate){
_piggate=piggate;
String UUID=Piggate.getMetadata(piggate.getApplicationContext(), "com.piggate.sdk.ApplicationUUID"); //Set the UUID
_region = new Region(piggate.getApplicationContext().getPackageName()+"-"+UUID, UUID, null, null); //Set the region
_beaconManager = new BeaconManager(piggate.getApplicationContext()); //Set the beacon manager
_beaconManager.setRangingListener(new BeaconManager.RangingListener() { //Set the ranging listener
//Handles the actions when the beacon are discovered
//Put the beacons into a list and send them into the piggatecallback object
@Override
synchronized public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
final ArrayList<PiggateBeacon> listBeacon=new ArrayList<PiggateBeacon>();
final ArrayList<PiggateBeacon> listBeacon2;
Beacon beacon;
for(int x=0;x<beacons.size();x++){
beacon=beacons.get(x);
listBeacon.add(new PiggateBeacon(beacon.getProximityUUID(),beacon.getMacAddress(),beacon.getMajor(),beacon.getMinor(),beacon.getMeasuredPower(),beacon.getRssi()));
}
listBeacon2=PiggateBeacon.registryBeacon(listBeacon);
if(listBeacon2.size()>0)
_piggatecallback.GetNewBeacons(listBeacon2);
PiggateBeacon.addPendingBeacons(listBeacon);
_piggatecallback.GetBeacons(listBeacon);
}
});
}
示例3: initializeEstimote
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
/**
* Initialize the Estimote Monitoring to check if a device enters the area of
* a selected Beacon to notify the Harvest time tracking
*/
private void initializeEstimote() {
// Initialize the Beacon manager
mBeaconManager = new BeaconManager(this);
mBeaconManager.setBackgroundScanPeriod(BEACON_SCAN_PERIOD, BEACON_WAIT_PERIOD);
mBeaconManager.setRangingListener(this);
// Connect to the Beacon Service
mBeaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
try {
mBeaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
Timber.i("Starting Ranging");
} catch (RemoteException e) {
Timber.d("Error while starting monitoring");
}
}
});
}
示例4: NearestBeaconManager
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
public NearestBeaconManager(Context context, List<BeaconID> beaconIDs) {
this.beaconIDs = beaconIDs;
beaconManager = new BeaconManager(context);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
checkForNearestBeacon(list);
}
});
}
示例5: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
RibotApplication.get(this).getComponent().inject(this);
mBus.register(this);
mMonitoredRegionsUuids = new HashSet<>();
mBeaconManager = new BeaconManager(this);
mBeaconManager.setMonitoringListener(this);
mBeaconManager.setRangingListener(this);
mBeaconManager.setForegroundScanPeriod(5000, 150000); // Scan during 5s every 2.5min
mBeaconManager.setBackgroundScanPeriod(10000, 300000); // Scan during 10s every 5min
}
示例6: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getActionBar().setDisplayHomeAsUpEnabled(true);
// Configure device list.
adapter = new BeaconListAdapter(this);
ListView list = (ListView) findViewById(R.id.device_list);
list.setAdapter(adapter);
list.setOnItemClickListener(createOnItemClickListener());
// Configure BeaconManager.
beaconManager = new BeaconManager(this);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
// Note that results are not delivered on UI thread.
runOnUiThread(new Runnable() {
@Override public void run() {
// Note that beacons reported here are already sorted by estimated
// distance between device and beacon.
getActionBar().setSubtitle("Found beacons: " + beacons.size());
adapter.replaceWith(beacons);
}
});
}
});
}
示例7: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Configure device list.
adapter = new LeDeviceListAdapter(this);
ListView list = (ListView) findViewById(R.id.device_list);
list.setAdapter(adapter);
list.setOnItemClickListener(createOnItemClickListener());
// Configure BeaconManager.
beaconManager = new BeaconManager(this);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
// Note that results are not delivered on UI thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
getActionBar().setSubtitle("Found beacons: " + beacons.size());
adapter.replaceWith(beacons);
}
});
}
});
}
示例8: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_proximizer);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
initFromPreferences();
View contentView = findViewById(R.id.baseview);
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setBackground(v);
updateValueFields(v);
}
});
beaconManager = new BeaconManager(this);
beaconManager.setBackgroundScanPeriod(scanInterval, scanPause);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
for (Beacon beacon : beacons) {
double acc = Utils.computeAccuracy(beacon);
int colorValue = scaleToColorValue(acc);
if (region.getIdentifier().equals(RED)) {
r = colorValue;
} else if (region.getIdentifier().equals(GREEN)) {
g = colorValue;
} else if (region.getIdentifier().equals(BLUE)) {
b = colorValue;
}
updateBackground();
}
}
});
}
示例9: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome_bird);
background = (RelativeLayout) findViewById(R.id.background);
accuracy = (TextView) findViewById(R.id.accuracy);
title = (TextView) findViewById(R.id.info_text);
bird = (ImageView) findViewById(R.id.bird);
// Configure BeaconManager.
beaconManager = new BeaconManager(this);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
// Note that results are not delivered on UI thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
// Note that beacons reported here are already sorted by estimated
// distance between device and beacon.
getActionBar().setSubtitle("Found beacons: " + beacons.size());
// Check if our beacon is in range.
boolean found = false;
double distance = 10000;
bird.clearAnimation();
bird.setImageResource(R.drawable.palermo);
for ( int i = 0 ; i < beacons.size(); i++) {
Beacon beacon = beacons.get(i);
if (beacon.getMajor()==46235 && beacon.getMinor()==34332 ) {
// found!
distance = Utils.computeAccuracy(beacon);
String t = String.format(getString(R.string.antonio_close),distance );
accuracy.setText(t);
found = true;
}
}
if ( found) {
//background.setBackgroundColor(0xff369ecc);
title.setText(getString(R.string.antonio_in_range));
bird.setImageResource(R.drawable.antonio);
if (distance<2) {
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
animation.getFillAfter();
animation.setDuration(1000);
animation.setRepeatCount(-1);
bird.startAnimation(animation);
}
else {
}
}
else {
//background.setBackgroundColor(0xffffffff);
accuracy.setText("");
title.setText(getString(R.string.welcome_jane));
bird.clearAnimation();
bird.setImageResource(R.drawable.palermo);
}
}
});
}
});
}
示例10: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_receiver);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// Configure BeaconManager.
beaconManager = new BeaconManager(this);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
// Note that results are not delivered on UI thread.
runOnUiThread(new Runnable() {
@Override
public void run() {
// Note that beacons reported here are already sorted by estimated
// distance between device and beacon.
// Check if our beacon is in range.
boolean found = false;
double distance = 10000;
for (int i = 0; i < beacons.size(); i++) {
Beacon beacon = beacons.get(i);
if (beacon.getMajor() == 46235 && beacon.getMinor() == 34332) {
// found!
distance = Utils.computeAccuracy(beacon);
String t = String.format(getString(R.string.antonio_close), distance);
found = true;
Log.i(TAG, "FOUND : "+t );
}
}
if (found) {
//background.setBackgroundColor(0xff369ecc);
if (distance < 10) {
mViewPager.setCurrentItem(1);
} else {
mViewPager.setCurrentItem(0);
}
} else {
mViewPager.setCurrentItem(0);
//background.setBackgroundColor(0xffffffff);
}
}
});
}
});
}
示例11: onReceive
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
beaconManager = new BeaconManager(context);
beaconList = new ArrayList<>(3);
beaconList.add(mBlueberry);
beaconList.add(mIce);
beaconList.add(mMint);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> rangedBeacons) {
Beacon foundBeacon = null;
for (Beacon rangedBeacon : rangedBeacons) {
for (Beacon supportedBeacon : beaconList) {
if (rangedBeacon.getMajor() == supportedBeacon.getMajor() && rangedBeacon.getMinor() == supportedBeacon.getMinor()) {
foundBeacon = rangedBeacon;
switch (foundBeacon.getName()) {
case BEACON_BLUEBERRY:
Log.i("TRAVELBIRD-BEACON", BEACON_BLUEBERRY + " found!");
break;
case BEACON_ICE:
Log.i("TRAVELBIRD-BEACON", BEACON_ICE + " found!");
break;
case BEACON_MINT:
Log.i("TRAVELBIRD-BEACON", BEACON_MINT + " found!");
break;
}
}
}
}
}
});
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
Log.i("TRAVELBIRD-BEACON", "CONNECT" + " found!");
}
});
}
示例12: onCreate
import com.estimote.sdk.BeaconManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
handler = new Handler();
// TODO add sensor data to stop/start beacon scanning
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
stepSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
sensorManager.registerListener(this, stepSensor,SensorManager.SENSOR_DELAY_NORMAL);
officeState = BeaconState.OUTSIDE;
houseRegion = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
beaconManager = new BeaconManager(getApplicationContext());
// Default values are 5s of scanning and 25s of waiting time to save CPU cycles.
// In order for this demo to be more responsive and immediate we lower down those values.
//beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(25));
//beaconManager.setForegroundScanPeriod(TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(10));
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
runOnUiThread(new Runnable() {
@Override
public void run() {
for (Beacon beacon : beacons) {
//Log.d(TAG, "MAC = " + beacon.getMacAddress() + ", RSSI = " + -beacon.getRssi());
// if (beacon.getMajor() == specialMajor && beacon.getMinor() == specialMinor ){
// specialBeacon = beacon;
// }
if(dismissIDs.indexOf(beacon.getMinor()) == -1 )
{
specialBeacon = beacon;
// dismissIDs.add(specialBeacon.getMinor());
}
}
if (specialBeacon != null){
double officeDistance = Utils.computeAccuracy(specialBeacon);
Log.d(TAG, "officeDistance: " + officeDistance);
if (officeDistance < enterThreshold && officeState == BeaconState.OUTSIDE){
officeState = BeaconState.INSIDE;
if(dismissIDs.indexOf(specialBeacon.getMinor()) == -1)
{
String url = "https://api.mongolab.com/api/1/databases/impulse/collections/beacons?apiKey=4fe65986e4b0cb519caaa0a3&q=%7" +
"Bmajor:"+specialBeacon.getMajor()+",minor:"+specialBeacon.getMinor()+"%7D";
new RequestTask().execute(url);
Log.d(TAG,"url: "+ url);
dismissIDs.add(specialBeacon.getMinor());
}
}else if (officeDistance > exitThreshold && officeState == BeaconState.INSIDE){
officeState = BeaconState.OUTSIDE;
MainActivity.unPublish();
}
}
else
{
Log.d(TAG,"no beacon");
}
}
});
}
});
//showNotification("hi");
//stopScanning();
startScanning();
}