本文整理汇总了Java中org.apache.cordova.api.CallbackContext.sendPluginResult方法的典型用法代码示例。如果您正苦于以下问题:Java CallbackContext.sendPluginResult方法的具体用法?Java CallbackContext.sendPluginResult怎么用?Java CallbackContext.sendPluginResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.api.CallbackContext
的用法示例。
在下文中一共展示了CallbackContext.sendPluginResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 A PluginResult object with a status and message.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;
JSONObject options = args.optJSONObject(0);
if (options != null)
{
this.targetHeight = options.getInt("targetHeight");
this.targetWidth = options.getInt("targetWidth");
this.mQuality = options.getInt("quality");
}
this.getImage();
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
示例2: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("start"))
{
this.callbackContext = paramCallbackContext;
if (this.status != RUNNING)
start();
}
while (true)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT, "");
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
if (!paramString.equals("stop"))
break;
if (this.status != RUNNING)
continue;
stop();
}
return false;
}
示例3: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* Executes the request.
*
* @param action The action to execute.
* @param args The exec() arguments.
* @param callbackId The callback id used when calling back into JavaScript.
* @return Whether the action was valid.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
if (action.equals("start")) {
this.callbackContext = callbackContext;
if (this.status != AccelListener.RUNNING) {
// If not running, then this is an async call, so don't worry about waiting
// We drop the callback onto our stack, call start, and let start and the sensor callback fire off the callback down the road
this.start();
}
}
else if (action.equals("stop")) {
if (this.status == AccelListener.RUNNING) {
this.stop();
}
} else {
// Unsupported action
return false;
}
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT, "");
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
return true;
}
示例4: 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 A PluginResult object with a status and message.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
if (action.equals("takePicture")) {
this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;
this.mQuality = args.getInt(0);
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
if (this.targetWidth < 1) {
this.targetWidth = -1;
}
if (this.targetHeight < 1) {
this.targetHeight = -1;
}
this.takePicture();
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}
示例5: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("getConnectionInfo"))
{
this.connectionCallbackContext = paramCallbackContext;
NetworkInfo localNetworkInfo = this.sockMan.getActiveNetworkInfo();
PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, getConnectionInfo(localNetworkInfo));
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
}
return false;
}
示例6: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
this.callbackContext = paramCallbackContext;
if (paramString.equals("takePicture"))
{
this.saveToPhotoAlbum = false;
this.targetHeight = 0;
this.targetWidth = 0;
this.encodingType = 0;
this.mediaType = 0;
this.mQuality = 80;
this.mQuality = paramJSONArray.getInt(0);
int i = paramJSONArray.getInt(1);
int j = paramJSONArray.getInt(2);
this.targetWidth = paramJSONArray.getInt(3);
this.targetHeight = paramJSONArray.getInt(4);
this.encodingType = paramJSONArray.getInt(5);
this.mediaType = paramJSONArray.getInt(6);
this.correctOrientation = paramJSONArray.getBoolean(8);
this.saveToPhotoAlbum = paramJSONArray.getBoolean(9);
if (this.targetWidth < 1)
this.targetWidth = -1;
if (this.targetHeight < 1)
this.targetHeight = -1;
if (j == 1)
takePicture(i, this.encodingType);
while (true)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
if ((j != 0) && (j != 2))
continue;
getImage(j, i);
}
}
return false;
}
示例7: 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;
}
示例8: 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;
}
示例9: getLocation
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
private boolean getLocation(JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
int i = paramJSONArray.getInt(2);
Location localLocation1 = this.gpsListener.getLastKnownLocation();
Location localLocation2 = this.networkListener.getLastKnownLocation();
Location localLocation3;
if ((localLocation1 != null) && (localLocation2 != null))
if (localLocation1.getTime() >= localLocation2.getTime())
localLocation3 = localLocation1;
while ((localLocation3 != null) && (System.currentTimeMillis() - localLocation3.getTime() <= i))
{
paramCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, returnLocationJSON(localLocation3)));
return true;
localLocation3 = localLocation2;
continue;
if (localLocation1 != null)
{
localLocation3 = localLocation1;
continue;
}
localLocation3 = null;
if (localLocation2 == null)
continue;
localLocation3 = localLocation2;
}
String str = paramJSONArray.getString(0);
WLLocationListener localWLLocationListener = getListener(paramJSONArray, 1, 3, paramCallbackContext);
if (localWLLocationListener == null)
return false;
localWLLocationListener.addCallback(str, paramCallbackContext, i);
return true;
}
示例10: doDispatch
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
private boolean doDispatch(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
ActionDispatcher localActionDispatcher = (ActionDispatcher)this.dispatchers.get(paramString);
if (logger.isLoggable(3))
logger.logDebug("dispatching action \"" + paramString + "\"");
if (localActionDispatcher == null)
{
paramCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "unable to dispatch action \"" + paramString + "\""));
return false;
}
executor.execute(new ActionDispatcherRunnable(localActionDispatcher, paramJSONArray, this.cordova, paramCallbackContext, null));
return true;
}
示例11: isEnabled
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* Is Bluetooth on.
*
* @param args Arguments given.
* @param callbackCtx Where to send results.
*/
private void isEnabled(JSONArray args, CallbackContext callbackCtx)
{
try
{
callbackCtx.sendPluginResult(new PluginResult(PluginResult.Status.OK, _bluetooth.isEnabled()));
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例12: isDiscovering
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* See if a device discovery process is in progress.
*
* @param args Arguments given.
* @param callbackCtx Where to send results.
*/
private void isDiscovering(JSONArray args, CallbackContext callbackCtx)
{
try
{
callbackCtx.sendPluginResult(new PluginResult(PluginResult.Status.OK, _bluetooth.isDiscovering()));
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例13: isPaired
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* See if the device is paired with the device in the given address.
*
* @param args Arguments given. First argument should be the address in String format.
* @param callbackCtx Where to send results.
*/
private void isPaired(JSONArray args, CallbackContext callbackCtx)
{
try
{
String address = args.getString(0);
callbackCtx.sendPluginResult(new PluginResult(PluginResult.Status.OK, _bluetooth.isBonded(address)));
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例14: isConnected
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
/**
* See if we have a connection.
*
* @param args Arguments given.
* @param callbackCtx Where to send results.
*/
private void isConnected(JSONArray args, CallbackContext callbackCtx)
{
try
{
callbackCtx.sendPluginResult(new PluginResult(PluginResult.Status.OK, _bluetooth.isConnected()));
}
catch(Exception e)
{
this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
}
}
示例15: execute
import org.apache.cordova.api.CallbackContext; //导入方法依赖的package包/类
@Override
public boolean execute(String action, String rawArgs, CallbackContext callbackContext) throws JSONException {
/*
* require to request as 'pick'
*/
if (action.equals("pick")) {
this.startContactActivity(callbackContext);
PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
pluginResult.setKeepCallback(true);
callbackContext.sendPluginResult(pluginResult);
return true;
}
return false;
}