Example usage for org.apache.cordova PluginResult PluginResult

List of usage examples for org.apache.cordova PluginResult PluginResult

Introduction

In this page you can find the example usage for org.apache.cordova PluginResult PluginResult.

Prototype

public PluginResult(Status status, List<PluginResult> multipartMessages) 

Source Link

Usage

From source file:com.emeth.cordova.ble.central.Peripheral.java

License:Apache License

@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    super.onServicesDiscovered(gatt, status);

    if (status == BluetoothGatt.GATT_SUCCESS) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, this.asJSONObject(gatt));
        result.setKeepCallback(true);/*  w w w  .  j  a  v a 2 s. c  o m*/
        connectCallback.sendPluginResult(result);
    } else {
        connectCallback.error("Service discovery failed. status = " + status);
        disconnect();
    }
}

From source file:com.emeth.cordova.ble.central.Peripheral.java

License:Apache License

@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
    super.onCharacteristicChanged(gatt, characteristic);
    LOG.d(TAG, "onCharacteristicChanged " + characteristic);

    CallbackContext callback = notificationCallbacks.get(generateHashKey(characteristic));

    if (callback != null) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, characteristic.getValue());
        result.setKeepCallback(true);//from  w  w  w . ja va  2s. co m
        callback.sendPluginResult(result);
    }
}

From source file:com.esri.cordova.geolocation.AdvancedGeolocation.java

License:Apache License

/**
 * Callback handler for this Class//from w w  w. ja  va 2s  .c om
 * @param status Message status
 * @param message Any message
 */
private static void sendCallback(PluginResult.Status status, String message) {
    final PluginResult result = new PluginResult(status, message);
    result.setKeepCallback(true);
    _callbackContext.sendPluginResult(result);
}

From source file:com.esri.cordova.geolocation.controllers.CellLocationController.java

License:Apache License

private static void sendCallback(PluginResult.Status status, String message) {
    if (!Thread.currentThread().isInterrupted()) {
        final PluginResult result = new PluginResult(status, message);
        result.setKeepCallback(true);// www  . j  a v  a2s .  c  om
        _callbackContext.sendPluginResult(result);
    }
}

From source file:com.esri.cordova.geolocation.controllers.GPSController.java

License:Apache License

/**
 * Callback handler for this Class/*from  www  .  j  a v  a  2 s.  c  om*/
 * @param status Message status
 * @param message Any message
 */
private static void sendCallback(PluginResult.Status status, String message) {
    if (!Thread.currentThread().isInterrupted()) {
        final PluginResult result = new PluginResult(status, message);
        result.setKeepCallback(true);
        _callbackContext.sendPluginResult(result);
    }
}

From source file:com.example.imageZoom.ActivityPlugin.java

License:Apache License

/**
 * Executes the request and returns PluginResult.
 *
 * @param action        The action to execute.
 * @param args          JSONArry of arguments for the plugin.
 * @param callbackId    The callback id used when calling back into JavaScript.
 * @return              A PluginResult object with a status and message.
 */// w w w  . j  a  va2 s .  com
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) {
    PluginResult result = new PluginResult(PluginResult.Status.OK, "");
    try {
        if (action.equals("start")) {
            this.startActivity(args.getString(0), args.getString(1));
            callbackContext.sendPluginResult(result);
            callbackContext.success();
            return true;
        }
    } catch (JSONException e) {
        result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, "JSON Exception");
        callbackContext.sendPluginResult(result);
        return false;
    }
    return false;
}

From source file:com.example.plugin.PhoneListener.java

License:Open Source License

/**
* Create a new plugin result and send it back to JavaScript
*
* @param phone state sent back to the designated success callback
*///  w ww .j a  v  a2  s  . co m
private void updatePhoneState(String phoneState, boolean keepCallback) {
    if (this.phoneListenerCallbackId != null) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, phoneState);
        result.setKeepCallback(keepCallback);
        this.phoneListenerCallbackId.sendPluginResult(result);
    }
    webView.postMessage("networkconnection", phoneState);
}

From source file:com.ezartech.ezar.flashlight.Flashlight.java

License:Open Source License

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults)
        throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext
                    .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }/*w ww.  jav  a  2 s .c  o m*/
    }
    switch (requestCode) {
    case CAMERA_SEC:
        init(this.callbackContext);
        break;
    }
}

From source file:com.ezartech.ezar.videooverlay.ezAR.java

License:Open Source License

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults)
        throws JSONException {

    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext
                    .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }//  ww w  .  j a v  a 2 s .c  o  m
    }
    switch (requestCode) {
    case CAMERA_SEC:
        init(null, this.callbackContext);
        break;
    }
}

From source file:com.ezartech.ezar.videooverlay.VideoOverlayPlugin.java

License:Open Source License

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults)
        throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext
                    .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }/*ww  w. j  av  a 2 s. c  o  m*/
    }
    switch (requestCode) {
    case CAMERA_SEC:
        init(null, this.callbackContext);
        break;
    }
}