本文整理汇总了Java中org.apache.cordova.CallbackContext.success方法的典型用法代码示例。如果您正苦于以下问题:Java CallbackContext.success方法的具体用法?Java CallbackContext.success怎么用?Java CallbackContext.success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.CallbackContext
的用法示例。
在下文中一共展示了CallbackContext.success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("hide")) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
webView.postMessage("splashscreen", "hide");
}
});
} else if (action.equals("show")) {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
webView.postMessage("splashscreen", "show");
}
});
} else {
return false;
}
callbackContext.success();
return true;
}
示例2: execute
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return True if the action was valid, false if not.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if ("getDeviceInfo".equals(action)) {
JSONObject r = new JSONObject();
r.put("uuid", Device.uuid);
r.put("version", this.getOSVersion());
r.put("platform", this.getPlatform());
r.put("model", this.getModel());
r.put("manufacturer", this.getManufacturer());
r.put("isVirtual", this.isVirtual());
r.put("serial", this.getSerialNumber());
callbackContext.success(r);
}
else {
return false;
}
return true;
}
示例3: jsSetPluginOptions
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
* Set plugin options. Method is called from JavaScript.
*
* @param arguments arguments from JavaScript
* @param callback callback where to send result
*/
@Deprecated
private void jsSetPluginOptions(CordovaArgs arguments, CallbackContext callback) {
if (!isPluginReadyForWork) {
sendPluginNotReadyToWork("", callback);
return;
}
try {
JSONObject jsonObject = (JSONObject) arguments.get(0);
chcpXmlConfig.mergeOptionsFromJs(jsonObject);
// TODO: store them somewhere?
} catch (JSONException e) {
Log.d("CHCP", "Failed to process plugin options, received from JS.", e);
}
callback.success();
}
示例4: 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;
}
示例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;
}
示例6: setFocusMode
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean setFocusMode(String focusMode, CallbackContext callbackContext) {
if(this.hasCamera(callbackContext) == false){
return true;
}
Camera camera = fragment.getCamera();
Camera.Parameters params = camera.getParameters();
List<String> supportedFocusModes;
List<String> supportedAutoFocusModes = Arrays.asList("auto", "continuous-picture", "continuous-video","macro");
supportedFocusModes = params.getSupportedFocusModes();
if (supportedFocusModes.indexOf(focusMode) > -1) {
params.setFocusMode(focusMode);
fragment.setCameraParameters(params);
callbackContext.success(focusMode);
return true;
} else {
callbackContext.error("Focus mode not recognised: " + focusMode);
return true;
}
}
示例7: execute
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
if (action.equals("upload") || action.equals("download")) {
String source = args.getString(0);
String target = args.getString(1);
if (action.equals("upload")) {
upload(source, target, args, callbackContext);
} else {
download(source, target, args, callbackContext);
}
return true;
} else if (action.equals("abort")) {
String objectId = args.getString(0);
abort(objectId);
callbackContext.success();
return true;
}
return false;
}
示例8: getSupportedFlashModes
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean getSupportedFlashModes(CallbackContext callbackContext) {
if(this.hasCamera(callbackContext) == false){
return true;
}
Camera camera = fragment.getCamera();
Camera.Parameters params = camera.getParameters();
List<String> supportedFlashModes;
supportedFlashModes = params.getSupportedFlashModes();
JSONArray jsonFlashModes = new JSONArray();
if (supportedFlashModes != null) {
for (int i=0; i<supportedFlashModes.size(); i++) {
jsonFlashModes.put(new String(supportedFlashModes.get(i)));
}
}
callbackContext.success(jsonFlashModes);
return true;
}
示例9: showCamera
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean showCamera(CallbackContext callbackContext) {
if(this.hasView(callbackContext) == false){
return true;
}
FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.show(fragment);
fragmentTransaction.commit();
callbackContext.success();
return true;
}
示例10: routeScreenOrientation
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {
String action = args.optString(0);
String orientation = args.optString(1);
Log.d(TAG, "Requested ScreenOrientation: " + orientation);
Activity activity = cordova.getActivity();
if (orientation.equals(ANY)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} else if (orientation.equals(LANDSCAPE_PRIMARY)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} else if (orientation.equals(PORTRAIT_PRIMARY)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (orientation.equals(LANDSCAPE)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else if (orientation.equals(PORTRAIT)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else if (orientation.equals(LANDSCAPE_SECONDARY)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
} else if (orientation.equals(PORTRAIT_SECONDARY)) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}
callbackContext.success();
return true;
}
示例11: executeUnconnect
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private PluginResult executeUnconnect(JSONArray args, final CallbackContext callbackContext){
Log.w(LOG_TAG, "executeUnconnect");
finding = false;
if (wifitosg != null)
wifitosg.UnConnect();
callbackContext.success();
return null;
}
示例12: 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());
}
}
示例13: getTriggeredIds
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
/**
* Set of IDs from all triggered notifications.
*
* @param command
* The callback context used when calling back into JavaScript.
*/
private void getTriggeredIds (CallbackContext command) {
List<Integer> ids = getNotificationMgr().getIdsByType(
Notification.Type.TRIGGERED);
command.success(new JSONArray(ids));
}
示例14: stopCamera
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private boolean stopCamera(CallbackContext callbackContext) {
if(this.hasView(callbackContext) == false){
return true;
}
FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove(fragment);
fragmentTransaction.commit();
fragment = null;
callbackContext.success();
return true;
}
示例15: stopLogging
import org.apache.cordova.CallbackContext; //导入方法依赖的package包/类
private void stopLogging(final CallbackContext callbackContext) {
if (this.bashExecuter != null) {
this.bashExecuter.killProcess();
this.bashExecuter = null;
}
if (this.loggerThread != null) {
this.loggerThread.interrupt();
this.loggerThread = null;
}
if (callbackContext != null) {
callbackContext.success();
}
}