List of usage examples for org.apache.cordova PluginResult setKeepCallback
public void setKeepCallback(boolean b)
From source file:nl.nielsad.cordova.wifiscanner.WifiListener.java
License:Apache License
private PluginResult sendPluginResult(PluginResult res) { res.setKeepCallback(true); this.callbackContext.sendPluginResult(res); return res;/*from w ww . j a v a 2s . c o m*/ }
From source file:org.apache.appharness.AppHarnessUI.java
License:Apache License
public void sendEvent(String eventName) { if (eventsCallback != null) { PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, eventName); pluginResult.setKeepCallback(true); eventsCallback.sendPluginResult(pluginResult); }/*from ww w . j a v a 2 s. co m*/ }
From source file:org.bcsphere.bclog.DebugRunnable.java
License:Apache License
@Override public void run() { Process mLogcatProc = null;//from ww w . java 2 s .c o m BufferedReader reader = null; try { mLogcatProc = Runtime.getRuntime().exec(filterLog); reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream())); String line; while (onOrOff) { line = reader.readLine(); if (line != null) { JSONObject obj = new JSONObject(); Tools.addProperty(obj, Tools.DATE, line); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); pluginResult.setKeepCallback(true); mCallback.sendPluginResult(pluginResult); } } } catch (Exception e) { e.printStackTrace(); } mCallback = null; }
From source file:org.bcsphere.bluetooth.BluetoothG43plus.java
License:Apache License
private void startScanManage(BluetoothDevice device, int rssi, byte[] scanRecord) { JSONObject obj = new JSONObject(); Tools.addProperty(obj, Tools.DEVICE_ADDRESS, device.getAddress()); Tools.addProperty(obj, Tools.DEVICE_NAME, device.getName()); Tools.addProperty(obj, Tools.IS_CONNECTED, Tools.IS_FALSE); Tools.addProperty(obj, Tools.RSSI, rssi); Tools.addProperty(obj, Tools.ADVERTISEMENT_DATA, Tools.decodeAdvData(scanRecord)); Tools.addProperty(obj, Tools.TYPE, "BLE"); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); addEventListenerCC.get(Tools.NEW_ADV_PACKET).sendPluginResult(pluginResult); }
From source file:org.bcsphere.bluetooth.BluetoothG43plus.java
License:Apache License
private void setNotificationManage(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { String deviceAddress = getDeviceAddress(gatt); if (setNotificationCC.get(characteristic) != null) { JSONObject obj = new JSONObject(); Tools.addProperty(obj, Tools.DEVICE_ADDRESS, deviceAddress); Tools.addProperty(obj, Tools.SERVICE_INDEX, recordServiceIndex.get(characteristic)); Tools.addProperty(obj, Tools.CHARACTERISTIC_INDEX, recordCharacteristicIndex.get(characteristic)); Tools.addProperty(obj, Tools.VALUE, Tools.encodeBase64(characteristic.getValue())); Tools.addProperty(obj, Tools.DATE, Tools.getDateString()); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); setNotificationCC.get(characteristic).sendPluginResult(pluginResult); }//from w ww.j a v a 2 s .c om }
From source file:org.bcsphere.bluetooth.BluetoothG43plus.java
License:Apache License
private void addEventListenerManage(BluetoothGatt gatt, int newState) { String deviceAddress = getDeviceAddress(gatt); if (newState == BluetoothGatt.STATE_DISCONNECTED) { mBluetoothGatts.get(deviceAddress).disconnect(); mBluetoothGatts.get(deviceAddress).close(); connectedDevice.remove(deviceAddress); mBluetoothGatts.remove(deviceAddress); JSONObject obj = new JSONObject(); Tools.addProperty(obj, Tools.DEVICE_ADDRESS, deviceAddress); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); addEventListenerCC.get(Tools.DISCONNECT).sendPluginResult(pluginResult); }//from www . j ava 2 s. c om }
From source file:org.chromium.BackgroundEventHandler.java
License:Open Source License
private void sendEventMessage(BackgroundEventInfo event) { JSONObject message = new JSONObject(); try {/* w w w . ja va 2s . c om*/ mapEventToMessage(event, message); } catch (JSONException e) { Log.e(LOG_TAG, "Failed to create background event message", e); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, message); pluginResult.setKeepCallback(true); messageChannel.sendPluginResult(pluginResult); }
From source file:org.chromium.BackgroundPlugin.java
License:Open Source License
private void sendEventMessage(String action, Object value) { if (messageChannel == null) { Log.w(LOG_TAG, "Message being dropped since channel not yet established: " + action); return;/*from w ww.j av a 2s . c o m*/ } JSONObject obj = new JSONObject(); try { obj.put("type", action); obj.put("value", value); } catch (JSONException e) { Log.e(LOG_TAG, "Failed to create background event", e); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); messageChannel.sendPluginResult(pluginResult); }
From source file:org.chromium.ChromeBluetooth.java
License:Open Source License
private static PluginResult getMultipartEventsResult(String eventType, JSONObject info) { List<PluginResult> multipartMessage = new ArrayList<PluginResult>(); multipartMessage.add(new PluginResult(Status.OK, eventType)); multipartMessage.add(new PluginResult(Status.OK, info)); PluginResult result = new PluginResult(Status.OK, multipartMessage); result.setKeepCallback(true); return result; }
From source file:org.chromium.ChromeBluetoothSocket.java
License:Open Source License
private void sendReceiveEvent(int socketId, byte[] data) { List<PluginResult> multipartMessage = new ArrayList<PluginResult>(); multipartMessage.add(new PluginResult(Status.OK, "onReceive")); multipartMessage.add(new PluginResult(Status.OK, socketId)); multipartMessage.add(new PluginResult(Status.OK, data)); PluginResult result = new PluginResult(Status.OK, multipartMessage); result.setKeepCallback(true); bluetoothSocketEventsCallback.sendPluginResult(result); }