本文整理汇总了Java中org.apache.cordova.api.CallbackContext.success方法的典型用法代码示例。如果您正苦于以下问题:Java CallbackContext.success方法的具体用法?Java CallbackContext.success怎么用?Java CallbackContext.success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.api.CallbackContext
的用法示例。
在下文中一共展示了CallbackContext.success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stopConnectionManager
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* Stop the managed connection, preventing further read or write operations.
*
* @param args Arguments given.
* @param callbackCtx Where to send results.
*/
private void stopConnectionManager(JSONArray args, CallbackContext callbackCtx)
{
try
{
if(_bluetooth.isConnectionManaged())
{
_bluetooth.stopConnectionManager();
callbackCtx.success();
}
else
{
this.error(callbackCtx,
"There is no connection being managed.",
BluetoothError.ERR_CONNECTION_DOESNT_EXIST
);
}
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例2: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
if (paramString.equals("getDeviceInfo"))
{
JSONObject localJSONObject = new JSONObject();
localJSONObject.put("uuid", uuid);
localJSONObject.put("version", getOSVersion());
localJSONObject.put("platform", platform);
localJSONObject.put("name", getProductName());
localJSONObject.put("cordova", cordovaVersion);
localJSONObject.put("model", getModel());
paramCallbackContext.success(localJSONObject);
return true;
}
return false;
}
示例3: getPaired
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* Get the devices paired with this device.
*
* @param args Arguments given.
* @param callbackCtx Where to send results.
*/
private void getPaired(JSONArray args, CallbackContext callbackCtx)
{
try
{
JSONArray devices = new JSONArray();
ArrayList<Pair<String>> bondedDevices = _bluetooth.getBondedDevices();
for(Pair<String> deviceInfo : bondedDevices)
{
JSONObject device = new JSONObject();
device.put("name", deviceInfo.a);
device.put("address", deviceInfo.b);
devices.put(device);
}
callbackCtx.success(devices);
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例4: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
try
{
ACTION_LOG localACTION_LOG = ACTION_LOG.fromString(paramString);
if (localACTION_LOG == null)
{
paramCallbackContext.error("Invalid action: " + paramString);
return true;
}
localACTION_LOG.log(this.cordova.getClass().getSimpleName(), paramJSONArray.getString(0));
paramCallbackContext.success("true");
return true;
}
catch (JSONException localJSONException)
{
paramCallbackContext.error("Action: " + paramString + " failed. JSON Error is: " + localJSONException.getLocalizedMessage());
}
return true;
}
示例5: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
try
{
if ("show".equals(paramString))
{
show(paramJSONArray);
paramCallbackContext.success(PluginResult.Status.OK.name());
return true;
}
paramCallbackContext.error("Invalid action: " + paramString);
return true;
}
catch (Exception localException)
{
WLUtils.debug("NativePage.show failed. Reason is: " + localException.getMessage(), localException);
paramCallbackContext.error("NativePage.show failed. Reason is: " + localException.getMessage());
}
return true;
}
示例6: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
boolean bool = paramString.equals("getcheckcode");
int i = 0;
if (bool);
try
{
paramCallbackContext.success(CheckCodeUtil.checkcode("", paramJSONArray.getString(0)));
i = 1;
return i;
}
catch (JSONException localJSONException)
{
paramCallbackContext.error("Failed to parse parameters");
}
return false;
}
示例7: execute
import org.apache.cordova.api.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 (action.equals("getDeviceInfo")) {
JSONObject r = new JSONObject();
r.put("uuid", Device.uuid);
r.put("version", this.getOSVersion());
r.put("platform", Device.platform);
r.put("cordova", Device.cordovaVersion);
r.put("model", this.getModel());
callbackContext.success(r);
}
else {
return false;
}
return true;
}
示例8: execute
import org.apache.cordova.api.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")) {
try {
source = URLDecoder.decode(source, "UTF-8");
upload(source, target, args, callbackContext);
} catch (UnsupportedEncodingException e) {
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.MALFORMED_URL_EXCEPTION, "UTF-8 error."));
}
} 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;
}
示例9: execute
import org.apache.cordova.api.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 context used when calling back into JavaScript.
* @return True if the action was valid, false otherwise.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
if (action.equals("openDatabase")) {
this.openDatabase(args.getString(0), args.getString(1),
args.getString(2), args.getLong(3));
} else if (action.equals("executeSql")) {
String[] s = null;
if (args.isNull(1)) {
s = new String[0];
} else {
JSONArray a = args.getJSONArray(1);
int len = a.length();
s = new String[len];
for (int i = 0; i < len; i++) {
s[i] = a.getString(i);
}
}
this.executeSql(args.getString(0), s, args.getString(2));
}
else {
return false;
}
callbackContext.success();
return true;
}
示例10: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
try
{
if ("show".equals(paramString))
{
show(paramJSONArray.getString(0));
paramCallbackContext.success("true");
return true;
}
if ("hide".equals(paramString))
{
hide();
paramCallbackContext.success("true");
return true;
}
}
catch (JSONException localJSONException)
{
paramCallbackContext.error("Action: " + paramString + " failed. JSON Error is: " + localJSONException.getLocalizedMessage());
return true;
}
paramCallbackContext.error("Invalid action: " + paramString);
return true;
}
示例11: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, CordovaArgs paramCordovaArgs, CallbackContext paramCallbackContext)
throws JSONException
{
if ("echo".equals(paramString))
{
boolean bool2 = paramCordovaArgs.isNull(0);
String str2 = null;
if (bool2);
while (true)
{
paramCallbackContext.success(str2);
return true;
str2 = paramCordovaArgs.getString(0);
}
}
if ("echoAsync".equals(paramString))
{
boolean bool1 = paramCordovaArgs.isNull(0);
String str1 = null;
if (bool1);
while (true)
{
this.cordova.getThreadPool().execute(new Runnable(paramCallbackContext, str1)
{
public void run()
{
this.val$callbackContext.success(this.val$result);
}
});
return true;
str1 = paramCordovaArgs.getString(0);
}
}
if ("echoArrayBuffer".equals(paramString))
{
paramCallbackContext.success(paramCordovaArgs.getArrayBuffer(0));
return true;
}
return false;
}
示例12: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("hide"))
this.webView.postMessage("splashscreen", "hide");
while (true)
{
paramCallbackContext.success();
return true;
if (!paramString.equals("show"))
break;
this.webView.postMessage("splashscreen", "show");
}
return false;
}
示例13: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
if ((paramString.equals("upload")) || (paramString.equals("download")))
{
String str1 = paramJSONArray.getString(0);
String str2 = paramJSONArray.getString(1);
if (paramString.equals("upload"))
try
{
upload(URLDecoder.decode(str1, "UTF-8"), str2, paramJSONArray, paramCallbackContext);
return true;
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
paramCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.MALFORMED_URL_EXCEPTION, "UTF-8 error."));
return true;
}
download(str1, str2, paramJSONArray, paramCallbackContext);
return true;
}
if (paramString.equals("abort"))
{
abort(paramJSONArray.getString(0));
paramCallbackContext.success();
return true;
}
return false;
}
示例14: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
int i;
if (paramString.equals("openDatabase"))
{
openDatabase(paramJSONArray.getString(0), paramJSONArray.getString(1), paramJSONArray.getString(2), paramJSONArray.getLong(3));
paramCallbackContext.success();
i = 1;
}
boolean bool;
do
{
return i;
bool = paramString.equals("executeSql");
i = 0;
}
while (!bool);
String[] arrayOfString;
if (paramJSONArray.isNull(1))
arrayOfString = new String[0];
while (true)
{
executeSql(paramJSONArray.getString(0), arrayOfString, paramJSONArray.getString(2));
break;
JSONArray localJSONArray = paramJSONArray.getJSONArray(1);
int j = localJSONArray.length();
arrayOfString = new String[j];
for (int k = 0; k < j; k++)
arrayOfString[k] = localJSONArray.getString(k);
}
}
示例15: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("start"))
{
if (this.batteryCallbackContext != null)
{
paramCallbackContext.error("Battery listener already running.");
return true;
}
this.batteryCallbackContext = paramCallbackContext;
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction("android.intent.action.BATTERY_CHANGED");
if (this.receiver == null)
{
this.receiver = new BroadcastReceiver()
{
public void onReceive(Context paramContext, Intent paramIntent)
{
BatteryListener.this.updateBatteryInfo(paramIntent);
}
};
this.cordova.getActivity().registerReceiver(this.receiver, localIntentFilter);
}
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
}
if (paramString.equals("stop"))
{
removeBatteryListener();
sendUpdate(new JSONObject(), false);
this.batteryCallbackContext = null;
paramCallbackContext.success();
return true;
}
return false;
}