没有合适的资源?快使用搜索试试~ 我知道了~
首页android获取ibeacon列表的方法
资源详情
资源评论
资源推荐

android获取获取ibeacon列表的方法列表的方法
主要为大家详细介绍了android获取ibeacon列表的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
android获取ibeacon列表,供大家参考,具体内容如下
最近公司有需要做ibeacon需求。
因为涉及扫码的时间。特意写一个service实现获取列表 可以根据扫描时间扫描出ibeacon列表
包含 uuid,设备名称,单位(米),电量等。
请根据自己的项目进行改造代码。
核心代码如下:
/**
*
* <ibeaon服务>
*
* @author fulushan
* @date 创建时间:2018年4月5日 下午11:34:04
*/
public class IbeaconService extends Service {
private static final String TAG = IbeaconService.class.getName();
ArrayList<IBeaconClass.iBeacon> mLeDevices;
private boolean mScanning;
private final static int DATA_COMPLETE = 0;
private final static int DATA_FAIL = 1;
/**搜索BLE终端*/
private BluetoothAdapter mBluetoothAdapter;
// Stops scanning after 10 seconds.
private static long SCAN_PERIOD = 10000;
ResponseResult responseResult = new ResponseResult();
public class IbeaconBinder extends Binder{
public ResponseResult getResponseResult(){
return responseResult;
}
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
if (intent != null) {
SCAN_PERIOD = intent.getIntExtra("time",10)*1000;
mLeDevices = new ArrayList<>();
//开启一个新的线程,如果使用Service,会导致ANR问题,Service本身也会阻塞
new Thread(new IbeaconRunnable()).start();
}
}
@Override
public void onDestroy() {
super.onDestroy();
stopUpdateService();
scanLeDevice(false);
}
class IbeaconRunnable implements Runnable {
Message message = handler.obtainMessage();
public void run() {
try {
//获取蓝牙数据














安全验证
文档复制为VIP权益,开通VIP直接复制

评论0