Need some help with the new Capture SDK for Android. I'm using the following code on an activity.
Capture.builder(getApplicationContext())
.enableLogging(BuildConfig.DEBUG)
.appKey(appKey)
.build();
captureClient = new CaptureClient(appKey);
captureClient.setListener(this);
captureClient.connect(connectionCallback);
I'm using my proper appKey with appid at the top level activity.
I would like to request battery level. How do I do this? I've implemented a listener but am not sure how to make the request.
Ok next I have this as the request:
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());
}
}
}
}
}
};
The code above does the round trip and the property callback is called but the information contained in the property is not the percentage.
This is the listener (which is never called) even though my class implements it and subscribes to 'things'.
@Override public void onBatteryLevelChanged(int i) {