use of com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback in project GwtMobile by dennisjzh.
the class BluetoothUi method listDevices.
public void listDevices() {
Bluetooth.listDevices(new StringCallback() {
@Override
public void onSuccess(String result) {
try {
String textHTML = "";
JSONValue value = JSONParser.parseLenient(result);
JSONArray devicesArray = value.isArray();
if (devicesArray != null) {
textHTML = "Result:";
for (int i = 0; i < devicesArray.size(); i++) {
JSONObject deviceObj = devicesArray.get(i).isObject();
textHTML = textHTML + "<br/>" + deviceObj.get("name");
}
text.setHTML(textHTML);
}
} catch (Exception e) {
e.printStackTrace();
text.setHTML("Error: " + e.getMessage());
}
}
@Override
public void onError(String message) {
text.setHTML("Error: " + message);
}
});
}
use of com.gwtmobile.phonegap.client.plugins.Bluetooth.StringCallback in project GwtMobile by dennisjzh.
the class BluetoothUi method listBoundDevices.
public void listBoundDevices() {
Bluetooth.listBoundDevices(new StringCallback() {
@Override
public void onSuccess(String result) {
try {
String textHTML = "";
JSONValue value = JSONParser.parseLenient(result);
JSONArray devicesArray = value.isArray();
if (devicesArray != null) {
textHTML = "Result:";
for (int i = 0; i < devicesArray.size(); i++) {
JSONObject deviceObj = devicesArray.get(i).isObject();
textHTML = textHTML + "<br/>" + deviceObj.get("name");
}
text.setHTML(textHTML);
}
} catch (Exception e) {
e.printStackTrace();
text.setHTML("Error: " + e.getMessage());
}
}
@Override
public void onError(String message) {
text.setHTML("Error: " + message);
}
});
}
Aggregations