Android 用の新しい Capture SDK に関するヘルプが必要です。アクティビティで次のコードを使用しています。
Capture.builder(getApplicationContext())
.enableLogging(BuildConfig.DEBUG)
.appKey(appKey)
.build();
captureClient = new CaptureClient(appKey);
captureClient.setListener(this);
captureClient.connect(connectionCallback);
トップレベルのアクティビティでappidを使用して適切なappKeyを使用しています。
バッテリー残量を教えてください。どうすればいいですか?リスナーを実装しましたが、リクエストの作成方法がわかりません。
次に、リクエストとしてこれがあります:
if (mDevice != null) {
mDevice.getBatteryLevel(propertyCallback);
}
PropertyCallback propertyCallback = new PropertyCallback() {
@Override
public void onComplete(@Nullable CaptureError captureError, @Nullable Property property) {
if (captureError != null) {
Log.d("onComplete", String.format("capture error %s", captureError.getMessage()));
} else {
if (property != null) {
Log.d("onComplete", String.format("property set %d", property.getId()));
Preference socketCharge = (Preference) findPreference("bt_scanner_battery_charge");
if (socketCharge != null) {
try {
int i = property.getInt();
socketCharge.setSummary(String.format("Current charge level: %d%%", i));
} catch (Exception e) {
Log.e("SocketChargeError", "" + e.getMessage());
}
}
}
}
}
};
上記のコードは往復を行い、プロパティ コールバックが呼び出されますが、プロパティに含まれる情報はパーセンテージではありません。
これは、私のクラスがそれを実装し、「もの」にサブスクライブしているにもかかわらず、リスナー (呼び出されることはありません) です。
@Override public void onBatteryLevelChanged(int i) {