Java Code Examples for org.apache.cordova.PluginResult.Status#OK

The following examples show how to use org.apache.cordova.PluginResult.Status#OK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TwilioVoicePlugin.java    From cordova-plugin-twiliovoicesdk with MIT License 6 votes vote down vote up
private void javascriptCallback(String event, JSONObject arguments,
                                CallbackContext callbackContext) {
    if (callbackContext == null) {
        return;
    }
    JSONObject options = new JSONObject();
    try {
        options.putOpt("callback", event);
        options.putOpt("arguments", arguments);
    } catch (JSONException e) {
        callbackContext.sendPluginResult(new PluginResult(
                PluginResult.Status.JSON_EXCEPTION));
        return;
    }
    PluginResult result = new PluginResult(Status.OK, options);
    result.setKeepCallback(true);
    callbackContext.sendPluginResult(result);

}
 
Example 2
Source File: WebSocketGenerator.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * Send plugin result.
 *
 * @param callbackString
 * @param keepCallback
 */
private void sendCallback(String callbackString, boolean keepCallback) {
    if (!_ctx.isFinished()) {
        PluginResult result = new PluginResult(Status.OK, callbackString);
        result.setKeepCallback(keepCallback);
        _ctx.sendPluginResult(result);
    }
}
 
Example 3
Source File: WebSocketGenerator.java    From IoTgo_Android_App with MIT License 5 votes vote down vote up
/**
 * Send plugin result.
 *
 * @param callbackString
 * @param keepCallback
 */
private void sendCallback(String callbackString, boolean keepCallback) {
    if (!_ctx.isFinished()) {
        PluginResult result = new PluginResult(Status.OK, callbackString);
        result.setKeepCallback(keepCallback);
        _ctx.sendPluginResult(result);
    }
}
 
Example 4
Source File: InAppServicePlugin.java    From atomic-plugins-inapps with Mozilla Public License 2.0 5 votes vote down vote up
@Override
  public void onPurchaseStart(InAppService sender, String productId)  {
if (listenerCtx != null) {
	JSONArray data = new JSONArray();
	data.put("start");
	data.put(productId);
	PluginResult result = new PluginResult(Status.OK, data);
	result.setKeepCallback(true);
	listenerCtx.sendPluginResult(result);
}
  }
 
Example 5
Source File: InAppServicePlugin.java    From atomic-plugins-inapps with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onPurchaseFail(InAppService sender, String productId, Error error) {
	if (listenerCtx != null) {
		JSONArray data = new JSONArray();
		data.put("error");
		data.put(productId);
		data.put(this.errorToJSON(error));
		PluginResult result = new PluginResult(Status.OK, data);
		result.setKeepCallback(true);
		listenerCtx.sendPluginResult(result);
	}
   }
 
Example 6
Source File: InAppServicePlugin.java    From atomic-plugins-inapps with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onPurchaseComplete(InAppService sender, InAppPurchase purchase){
	if (listenerCtx != null) {
		JSONArray data = new JSONArray();
		data.put("complete");
		data.put(purchase.toJSON());
		PluginResult result = new PluginResult(Status.OK, data);
		result.setKeepCallback(true);
		listenerCtx.sendPluginResult(result);
	}
   }
 
Example 7
Source File: WebSocketGenerator.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Send plugin result.
 *
 * @param callbackString
 * @param keepCallback
 */
private void sendCallback(String callbackString, boolean keepCallback) {
    if (!_ctx.isFinished()) {
        PluginResult result = new PluginResult(Status.OK, callbackString);
        result.setKeepCallback(keepCallback);
        _ctx.sendPluginResult(result);
    }
}
 
Example 8
Source File: BackgroundModeExt.java    From cordova-plugin-background-mode with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the callback with information if the screen is on.
 *
 * @param callback The callback to invoke.
 */
@SuppressWarnings("deprecation")
private void isDimmed (CallbackContext callback)
{
    boolean status   = isDimmed();
    PluginResult res = new PluginResult(Status.OK, status);

    callback.sendPluginResult(res);
}