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


Java CallbackContext类代码示例

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


CallbackContext类属于org.apache.cordova.api包,在下文中一共展示了CallbackContext类的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;
  }
 
开发者ID:AlunoTADS,项目名称:foreground-gallery-plugin,代码行数:32,代码来源:ForegroundGalleryLauncher.java

示例2: execute

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if ("showEmailComposer".equals(action)) {
                
                try {
                        JSONObject parameters = args.getJSONObject(0);
                        if (parameters != null) {
                                sendEmail(parameters);
                        }
                } catch (Exception e) {

                }
                callbackContext.success();
                return true;
        }
        return false;  // Returning false results in a "MethodNotFound" error.
}
 
开发者ID:inorganik,项目名称:cordova-emailComposerWithAttachments,代码行数:18,代码来源:EmailComposer.java

示例3: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:AccelListener.java

示例4: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:18,代码来源:Device.java

示例5: win

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
private void win(Location paramLocation)
{
  Iterator localIterator1 = this.callbacks.iterator();
  while (localIterator1.hasNext())
  {
    CallbackContext localCallbackContext = (CallbackContext)localIterator1.next();
    this.owner.win(paramLocation, localCallbackContext);
  }
  if (this.owner.isGlobalListener(this))
  {
    Log.d(this.TAG, "Stopping global listener");
    stop();
  }
  this.callbacks.clear();
  Iterator localIterator2 = this.watches.values().iterator();
  while (localIterator2.hasNext())
    this.owner.win(paramLocation, (CallbackContext)localIterator2.next());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:CordovaLocationListener.java

示例6: fail

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
protected void fail(int paramInt, String paramString)
{
  Iterator localIterator1 = this.callbacks.iterator();
  while (localIterator1.hasNext())
  {
    CallbackContext localCallbackContext = (CallbackContext)localIterator1.next();
    this.owner.fail(paramInt, paramString, localCallbackContext);
  }
  if (this.owner.isGlobalListener(this))
  {
    Log.d(this.TAG, "Stopping global listener");
    stop();
  }
  this.callbacks.clear();
  Iterator localIterator2 = this.watches.values().iterator();
  while (localIterator2.hasNext())
    this.owner.fail(paramInt, paramString, (CallbackContext)localIterator2.next());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:CordovaLocationListener.java

示例7: execute

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
  throws JSONException
{
  this.ctx = this.cordova.getActivity();
  try
  {
    this.wifiManager = ((WifiManager)this.ctx.getSystemService("wifi"));
    Action localAction = Action.valueOf(toAllCaps(paramString));
    Log.d("Wifi", "WifiPlugin called with action: " + localAction);
    switch (2.$SwitchMap$com$worklight$androidgap$plugin$WifiPlugin$Action[localAction.ordinal()])
    {
    case 1:
      scanWifi(paramCallbackContext);
      return true;
    }
  }
  catch (Exception localException)
  {
    Log.e("Wifi", "Error initializing WIFI scanning, reason: " + localException.getMessage());
    return false;
  }
  return false;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:WifiPlugin.java

示例8: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:Logger.java

示例9: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:27,代码来源:BusyIndicator.java

示例10: win

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
private void win(Location paramLocation)
{
  long l = System.currentTimeMillis() - paramLocation.getTime();
  if (l > this.maximumAge)
    Log.d(this.TAG, "Acquired location age: " + l + " milliseconds. More than maximumAge of " + this.maximumAge + " milliseconds. Ignoring.");
  do
  {
    return;
    Iterator localIterator1 = this.callbacks.values().iterator();
    while (localIterator1.hasNext())
      this.owner.win(paramLocation, (CallbackContext)localIterator1.next(), false);
    if ((this.owner.isGlobalListener(this)) && (this.watches.size() == 0))
    {
      Log.d(this.TAG, "Stopping global listener");
      stop();
    }
    this.callbacks.clear();
    Iterator localIterator2 = this.watches.values().iterator();
    while (localIterator2.hasNext())
      this.owner.win(paramLocation, (CallbackContext)localIterator2.next(), true);
  }
  while (!this.watches.isEmpty());
  stop();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:25,代码来源:WLLocationListener.java

示例11: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:NativePage.java

示例12: execute

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
  throws JSONException
{
  Log.d("WLForegroundBinder", "execute called");
  this.ctx = this.cordova.getActivity();
  try
  {
    Action localAction = Action.valueOf(toAllCaps(paramString));
    switch (2.$SwitchMap$com$worklight$androidgap$plugin$ForegroundBinderPlugin$Action[localAction.ordinal()])
    {
    case 1:
      bindService(paramJSONArray, paramCallbackContext);
      return true;
    case 2:
      unbindService(paramCallbackContext);
      return false;
    }
  }
  catch (IllegalArgumentException localIllegalArgumentException)
  {
  }
  return false;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:ForegroundBinderPlugin.java

示例13: 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;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:CheckCodePlugin.java

示例14: error

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
/**
 * Send an error to given CallbackContext containing the error code and message.
 * 
 * @param ctx	Where to send the error.
 * @param msg	What seems to be the problem.
 * @param code	Integer value as a an error "code"
 */
private void error(CallbackContext ctx, String msg, int code)
{
	try
	{
		JSONObject result = new JSONObject();
		result.put("message", msg);
		result.put("code", code);
		
		ctx.error(result);
	}
	catch(Exception e)
	{
		Log.e(LOG_TAG, "Error with... error raising, " + e.getMessage());
	}
}
 
开发者ID:nadavelyashiv,项目名称:metal-finder-new,代码行数:23,代码来源:BluetoothPlugin.java

示例15: pair

import org.apache.cordova.api.CallbackContext; //导入依赖的package包/类
/**
 * Pair the device 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 pair(JSONArray args, CallbackContext callbackCtx)
{
	// TODO Add a timeout function for pairing
	
	if(_pairingCallback != null)
	{
		this.error(callbackCtx, "Pairing process is already in progress.", BluetoothError.ERR_PAIRING_IN_PROGRESS);
	}
	else
	{
		try
		{
			String address = args.getString(0);
			_bluetooth.createBond(address);
			_pairingCallback = callbackCtx;
		}
		catch(Exception e)
		{
			_pairingCallback = null;
			this.error(callbackCtx, e.getMessage(), BluetoothError.ERR_UNKNOWN);
		}
	}
}
 
开发者ID:nadavelyashiv,项目名称:metal-finder-new,代码行数:30,代码来源:BluetoothPlugin.java


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