当前位置: 首页>>代码示例>>Java>>正文


Java CallbackContext.error方法代码示例

本文整理汇总了Java中org.apache.cordova.CallbackContext.error方法的典型用法代码示例。如果您正苦于以下问题:Java CallbackContext.error方法的具体用法?Java CallbackContext.error怎么用?Java CallbackContext.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cordova.CallbackContext的用法示例。


在下文中一共展示了CallbackContext.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFlashMode

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean setFlashMode(String flashMode, CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  List<String> supportedFlashModes;
  supportedFlashModes = camera.getParameters().getSupportedFlashModes();
  if (supportedFlashModes.indexOf(flashMode) > -1) {
    params.setFlashMode(flashMode);
  } else {
    callbackContext.error("Flash mode not recognised: " + flashMode);
    return true;
  }

  fragment.setCameraParameters(params);

  callbackContext.success(flashMode);
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:23,代码来源:CameraPreview.java

示例2: _uninstall

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void _uninstall(String packageId, CallbackContext callbackContext) throws JSONException {
	if (this._appIsInstalled(packageId)) {
		Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
		intent.setData(Uri.parse("package:" + packageId));
		cordova.getActivity().startActivity(intent);
		callbackContext.success();
	}
	else {
		JSONObject errorObj = new JSONObject();
		errorObj.put("status", PluginResult.Status.ERROR.ordinal());
		errorObj.put("message", "This package is not installed");
		callbackContext.error(errorObj);
	}
}
 
开发者ID:Edc-zhang,项目名称:cordova-plugin-file-opener2-android7.0,代码行数:15,代码来源:FileOpener2.java

示例3: setZoom

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean setZoom(int zoom, CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  if (camera.getParameters().isZoomSupported()) {
    params.setZoom(zoom);
    fragment.setCameraParameters(params);

    callbackContext.success(zoom);
  } else {
    callbackContext.error("Zoom not supported");
  }

  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:20,代码来源:CameraPreview.java

示例4: write

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void write(CallbackContext callbackContext, String macAddress, UUID serviceUUID, UUID characteristicUUID,
                   byte[] data, int writeType) {

    Peripheral peripheral = peripherals.get(macAddress);

    if (peripheral == null) {
        callbackContext.error("Peripheral " + macAddress + " not found.");
        return;
    }

    if (!peripheral.isConnected()) {
        callbackContext.error("Peripheral " + macAddress + " is not connected.");
        return;
    }

    //peripheral.writeCharacteristic(callbackContext, serviceUUID, characteristicUUID, data, writeType);
    peripheral.queueWrite(callbackContext, serviceUUID, characteristicUUID, data, writeType);

}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:20,代码来源:BLECentralPlugin.java

示例5: setExposureCompensation

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean setExposureCompensation(int exposureCompensation, CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  int minExposureCompensation = camera.getParameters().getMinExposureCompensation();
  int maxExposureCompensation = camera.getParameters().getMaxExposureCompensation();

  if ( minExposureCompensation == 0 && maxExposureCompensation == 0) {
    callbackContext.error("Exposure corection not supported");
  } else {
    if (exposureCompensation < minExposureCompensation) {
      exposureCompensation = minExposureCompensation;
    } else if (exposureCompensation > maxExposureCompensation) {
      exposureCompensation = maxExposureCompensation;
    }
    params.setExposureCompensation(exposureCompensation);
    fragment.setCameraParameters(params);

    callbackContext.success(exposureCompensation);
  }
return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:27,代码来源:CameraPreview.java

示例6: getExposureMode

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean getExposureMode(CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  String exposureMode;

  if (camera.getParameters().isAutoExposureLockSupported()) {
    if (camera.getParameters().getAutoExposureLock()) {
      exposureMode = "lock";
    } else {
      exposureMode = "continuous";
    };
    callbackContext.success(exposureMode);
  } else {
    callbackContext.error("Exposure mode not supported");
  }
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:23,代码来源:CameraPreview.java

示例7: getWhiteBalanceMode

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean getWhiteBalanceMode(CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  String whiteBalanceMode;

  if (camera.getParameters().isAutoWhiteBalanceLockSupported()) {
    if (camera.getParameters().getAutoWhiteBalanceLock()) {
      whiteBalanceMode = "lock";
    } else {
      whiteBalanceMode = camera.getParameters().getWhiteBalance();
    };
  } else {
    whiteBalanceMode = camera.getParameters().getWhiteBalance();
  }
  if (whiteBalanceMode != null) {
    callbackContext.success(whiteBalanceMode);
  } else {
    callbackContext.error("White balance mode not supported");
  }
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:27,代码来源:CameraPreview.java

示例8: readRSSI

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void readRSSI(CallbackContext callbackContext) {

        boolean success = false;

        if (gatt == null) {
            callbackContext.error("BluetoothGatt is null");
            return;
        }

        readCallback = callbackContext;

        if (gatt.readRemoteRssi()) {
            success = true;
        } else {
            readCallback = null;
            callbackContext.error("Read RSSI failed");
        }

        if (!success) {
            commandCompleted();
        }

    }
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:24,代码来源:Peripheral.java

示例9: setColorEffect

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean setColorEffect(String effect, CallbackContext callbackContext) {
  if(this.hasCamera(callbackContext) == false){
    return true;
  }

  Camera camera = fragment.getCamera();
  Camera.Parameters params = camera.getParameters();

  if (effect.equals(Camera.Parameters.EFFECT_AQUA)) {
    params.setColorEffect(Camera.Parameters.EFFECT_AQUA);
  } else if (effect.equals(Camera.Parameters.EFFECT_BLACKBOARD)) {
    params.setColorEffect(Camera.Parameters.EFFECT_BLACKBOARD);
  } else if (effect.equals(Camera.Parameters.EFFECT_MONO)) {
    params.setColorEffect(Camera.Parameters.EFFECT_MONO);
  } else if (effect.equals(Camera.Parameters.EFFECT_NEGATIVE)) {
    params.setColorEffect(Camera.Parameters.EFFECT_NEGATIVE);
  } else if (effect.equals(Camera.Parameters.EFFECT_NONE)) {
    params.setColorEffect(Camera.Parameters.EFFECT_NONE);
  } else if (effect.equals(Camera.Parameters.EFFECT_POSTERIZE)) {
    params.setColorEffect(Camera.Parameters.EFFECT_POSTERIZE);
  } else if (effect.equals(Camera.Parameters.EFFECT_SEPIA)) {
    params.setColorEffect(Camera.Parameters.EFFECT_SEPIA);
  } else if (effect.equals(Camera.Parameters.EFFECT_SOLARIZE)) {
    params.setColorEffect(Camera.Parameters.EFFECT_SOLARIZE);
  } else if (effect.equals(Camera.Parameters.EFFECT_WHITEBOARD)) {
    params.setColorEffect(Camera.Parameters.EFFECT_WHITEBOARD);
  } else {
    callbackContext.error("Color effect not supported" + effect);
    return true;
  }

  fragment.setCameraParameters(params);

  callbackContext.success(effect);
  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:37,代码来源:CameraPreview.java

示例10: sendNotification

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
public static void sendNotification(Bundle bundle) {
    if (!MessagingComponent.hasNotificationsCallback()) {
        MessagingComponent.initialize(bundle);
        return;
    }

    Log.i(TAG, "Sending notification");

    final CallbackContext callbackContext = MessagingComponent.notificationCallbackContext;
    if (callbackContext != null && bundle != null) {
        JSONObject json = new JSONObject();
        Set<String> keys = bundle.keySet();
        for (String key : keys) {
            try {
                json.put(key, bundle.get(key));
            } catch (JSONException e) {
                Log.i(TAG, "Error sending notification: " + e.getMessage());
                callbackContext.error(e.getMessage());
                return;
            }
        }

        PluginResult pluginresult = new PluginResult(PluginResult.Status.OK, json);
        pluginresult.setKeepCallback(true);
        callbackContext.sendPluginResult(pluginresult);
    }
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:28,代码来源:MessagingComponent.java

示例11: execute

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
 * Executes the request and returns a boolean.
 * 
 * @param action
 *            The action to execute.
 * @param args
 *            JSONArry of arguments for the plugin.
 * @param callbackContext
 *            The callback context used when calling back into JavaScript.
 * @return boolean.
 */
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
	if (action.equals("open")) {
		this._open(args.getString(0), args.getString(1), callbackContext);
	} 
	else if (action.equals("uninstall")) {
		this._uninstall(args.getString(0), callbackContext);
	}
	else if (action.equals("appIsInstalled")) {
		JSONObject successObj = new JSONObject();
		if (this._appIsInstalled(args.getString(0))) {
			successObj.put("status", PluginResult.Status.OK.ordinal());
			successObj.put("message", "Installed");
		}
		else {
			successObj.put("status", PluginResult.Status.NO_RESULT.ordinal());
			successObj.put("message", "Not installed");
		}
		callbackContext.success(successObj);
	}
	else {
		JSONObject errorObj = new JSONObject();
		errorObj.put("status", PluginResult.Status.INVALID_ACTION.ordinal());
		errorObj.put("message", "Invalid action");
		callbackContext.error(errorObj);
	}
	return true;
}
 
开发者ID:Edc-zhang,项目名称:cordova-plugin-file-opener2-android7.0,代码行数:39,代码来源:FileOpener2.java

示例12: hasCamera

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean hasCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return false;
  }

  if(fragment.getCamera() == null) {
    callbackContext.error("No Camera");
    return false;
  }

  return true;
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:13,代码来源:CameraPreview.java

示例13: showInFileManager

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void showInFileManager(final CallbackContext callbackContext) {
    if (this.checkStoragePermission()) {
        final Runnable showFileManager = new Runnable() {
            @Override
            public void run() {
                prepareFilesToShow(callbackContext);
                callbackContext.success();
            }
        };
        cordovaInstance.getThreadPool().execute(showFileManager);
    } else {
        callbackContext.error(RETURN_CODE.NO_EXTERNAL_STORAGE_PERMISSIONS.name());
    }
}
 
开发者ID:kolbasa,项目名称:cordova-logcat-filelogger,代码行数:15,代码来源:LogCatPlugin.java

示例14: getJcLogPath

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void getJcLogPath(final CallbackContext callbackContext) {
    final File fileToCopy = FileTools.prepareDownload(lcFile, lcBak, lcCon);
    if (fileToCopy != null && fileToCopy.exists()) {
        callbackContext.success(fileToCopy.getAbsolutePath());
    } else {
        callbackContext.error(RETURN_CODE.NO_LOG_FILES_FOUND.name());
    }
}
 
开发者ID:kolbasa,项目名称:cordova-logcat-filelogger,代码行数:9,代码来源:LogCatPlugin.java

示例15: execute

import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    
    Log.d(TAG, "execute action: " + action);
    
    // Route the Action
    if (action.equals("screenOrientation")) {
        return routeScreenOrientation(args, callbackContext);
    }
    
    // Action not found
    callbackContext.error("action not recognised");
    return false;
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:15,代码来源:CDVOrientation.java


注:本文中的org.apache.cordova.CallbackContext.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。