0
私はAltBeacon Androidビーコンライブラリに問題がありますが、私はすべてのパーミッション(BLUETOOTH, BLUETOOTH_ADMIN, ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
)を設定していますが、何らかの理由で私のアプリがビーコンを検出できませんいくつか異なる)。私はアンドロイド6.0.1でサムスンギャラクシータブを使用しています。 私は私のアプリを実行している間、私はこのメッセージを得る: Android 6.0.1 API 23 - ビーコンライブラリが動作しない
I/BeaconActivity: I have just switched from seeing/not seeing beacons: 0
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 48 - 0, 0) vi=Rect(0, 48 - 0, 0) or=1
D/libGLESv1: STS_GLApi : DTS is not allowed for Package : com.example.tgesior.beacons
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Start Scan
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
I/Timeline: Timeline: Activity_idle id: [email protected] time:32794199
D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/ScanRecord: parseFromBytes
D/ScanRecord: first manudata for manu ID
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan
D/BluetoothLeScanner: Start Scan
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
をというように、ここに私のコードは次のとおりです。
private BeaconManager beaconManager =null;
private static final String ALTBEACON_LAYOUT = "m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25";
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_beacon);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("This app needs location access");
builder.setMessage("Please grant location access so this app can detect beacons.");
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);
}
});
builder.show();
}
}
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(ALTBEACON_LAYOUT));
beaconManager.setForegroundScanPeriod(30000l);
beaconManager.setForegroundBetweenScanPeriod(21000l);
beaconManager.bind(this);
}
public void onRequestPermissionsResult(int requestCode,
String permissions[],
int[] grantResults) {
switch (requestCode) {
case PERMISSION_REQUEST_COARSE_LOCATION: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "coarse location permission granted");
} else {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Functionality limited");
builder.setMessage("Since location access has not been granted, this app will not be able to discover beacons when in the background.");
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
});
builder.show();
}
return;
}
}
}
@Override
public void onBeaconServiceConnect() {
beaconManager.addMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an beacon for the first time!");
}
@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an beacon");
}
@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
これは代替ビーコンですか? – dazza5000
はいこれはaltビーコン用です – drPAYMENT