gpt4 book ai didi

java - android-Altbeacons 路径错误

转载 作者:行者123 更新时间:2023-12-01 10:30:31 31 4
gpt4 key购买 nike

我尝试使用 altBeacon 库查找 iBeacon,但收到此错误:

01-31 11:34:08.628 31582-31582/es.deusto.beaconsapp2 I/art: Late-enabling -Xcheck:jni
01-31 11:34:08.700 31582-31582/es.deusto.beaconsapp2 W/System: ClassLoader referenced unknown path: /data/app/es.deusto.beaconsapp2-1/lib/arm
01-31 11:34:08.713 31582-31582/es.deusto.beaconsapp2 D/BeaconParser: Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
01-31 11:34:08.715 31582-31582/es.deusto.beaconsapp2 D/BeaconParser: Parsing beacon layout: m:2-3=0x0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
01-31 11:34:08.749 31582-31597/es.deusto.beaconsapp2 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
01-31 11:34:08.772 31582-31582/es.deusto.beaconsapp2 W/BluetoothCrashResolver: Can't read macs from BluetoothCrashResolverState.txt
01-31 11:34:08.803 31582-31600/es.deusto.beaconsapp2 W/DistanceConfigFetcher: Can't reach server
01-31 11:34:08.804 31582-31600/es.deusto.beaconsapp2 W/ModelSpecificDistanceCalculator: Cannot updated distance models from online database at java.net.UnknownHostException: Unable to resolve host "data.altbeacon.org": No address associated with hostname
01-31 11:34:08.892 31582-31597/es.deusto.beaconsapp2 I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb
01-31 11:34:08.895 31582-31597/es.deusto.beaconsapp2 I/OpenGLRenderer: Initialized EGL, version 1.4
01-31 11:34:08.985 31582-31582/es.deusto.beaconsapp2 D/BluetoothAdapter: STATE_ON
01-31 11:34:08.987 31582-31594/es.deusto.beaconsapp2 D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: Caught a RuntimeException from the binder stub implementation.
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.os.Parcel.readException(Parcel.java:1620)
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.os.Parcel.readException(Parcel.java:1573)
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:772)
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:324)
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56)
01-31 11:34:08.989 31582-31594/es.deusto.beaconsapp2 W/Binder: at android.os.Binder.execTransact(Binder.java:453)

我下载了 altBeacon 库并移动到我的项目的“library”文件夹中。然后我将 compile 'org.altbeacon:android-beacon-library:2+' 行放入应用程序的 gradle 中。我使用的类是:

     public class MainActivity extends Activity implements BeaconConsumer{


private static final String TAG = "BeaconReferenceApp";
private BeaconManager beaconManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().clear();
//i think that i should use "0x0215"
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:2-3=0x0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
beaconManager.bind(this);

//I link the activity with the layout
setContentView(R.layout.activity_main);
}

@Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
}


@Override
public void onBeaconServiceConnect() {
//I use the ID of my beacon
final Region region = new Region("myBeacons", Identifier.parse("A7AE2EB71F004168B99BA749BAC1CA64"), null, null);
beaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
try {
Log.d(TAG, "didEnterRegion");
beaconManager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
}

@Override
public void didExitRegion(Region region) {
try {
Log.d(TAG, "didExitRegion");
beaconManager.stopRangingBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
}

@Override
public void didDetermineStateForRegion(int i, Region region) {

}
});

//i set the notifier
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
for (Beacon oneBeacon : beacons) {
Log.d(TAG, "distance: " + oneBeacon.getDistance() + " id:" + oneBeacon.getId1() + "/" + oneBeacon.getId2() + "/" + oneBeacon.getId3());
}
}
});

try {
beaconManager.startMonitoringBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}

}
}

最佳答案

Android 6 现在要求应用程序扫描 BLE 信标以获得访问位置的运行时权限。

您可以在我的博客文章中阅读有关如何执行此操作的完整详细信息:

http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html}

关于java - android-Altbeacons 路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35113242/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com