當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。