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


Java Status.JSON_EXCEPTION属性代码示例

本文整理汇总了Java中org.apache.cordova.PluginResult.Status.JSON_EXCEPTION属性的典型用法代码示例。如果您正苦于以下问题:Java Status.JSON_EXCEPTION属性的具体用法?Java Status.JSON_EXCEPTION怎么用?Java Status.JSON_EXCEPTION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.cordova.PluginResult.Status的用法示例。


在下文中一共展示了Status.JSON_EXCEPTION属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeEnableWifi

private PluginResult executeEnableWifi(JSONArray inputs, CallbackContext callbackContext) {
  	Log.w(LOGTAG, "executeEnableWifi");

Context context = cordova.getActivity().getApplicationContext();
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

boolean toEnable = true;
try {
	toEnable = inputs.getBoolean( 0 );
} catch (JSONException e) {
      Log.w(LOGTAG, String.format("Got JSON Exception: %s", e.getMessage()));
      return new PluginResult(Status.JSON_EXCEPTION);
}
      
wifiManager.setWifiEnabled( toEnable );
callbackContext.success();

  	return null;
  }
 
开发者ID:floatinghotpot,项目名称:cordova-plugin-wifi,代码行数:19,代码来源:WifiAdmin.java

示例2: executeCreateBannerView

/**
 * Parses the create banner view input parameters and runs the create banner
 * view action on the UI thread.  If this request is successful, the developer
 * should make the requestAd call to request an ad for the banner.
 *
 * @param inputs The JSONArray representing input parameters.  This function
 *        expects the first object in the array to be a JSONObject with the
 *        input parameters.
 * @return A PluginResult representing whether or not the banner was created
 *         successfully.
 */
private PluginResult executeCreateBannerView(JSONArray inputs) {
  String publisherId;
  String size;

  // Get the input data.
  try {
    publisherId = inputs.getString( PUBLISHER_ID_ARG_INDEX );
    size = inputs.getString( AD_SIZE_ARG_INDEX );
    this.bannerAtTop = inputs.getBoolean( POSITION_AT_TOP_ARG_INDEX );
  	
  } catch (JSONException exception) {
    Log.w(LOGTAG, String.format("Got JSON Exception: %s", exception.getMessage()));
    return new PluginResult(Status.JSON_EXCEPTION);
  }

  // Create the AdView on the UI thread.
  return executeRunnable(new CreateBannerViewRunnable(
      publisherId, adSizeFromSize(size)));
}
 
开发者ID:psydrake,项目名称:litecoinEasyCheck,代码行数:30,代码来源:AdMob.java

示例3: executeRequestAd

/**
 * Parses the request ad input parameters and runs the request ad action on
 * the UI thread.
 *
 * @param inputs The JSONArray representing input parameters.  This function
 *        expects the first object in the array to be a JSONObject with the
 *        input parameters.
 * @return A PluginResult representing whether or not an ad was requested
 *         succcessfully.  Listen for onReceiveAd() and onFailedToReceiveAd()
 *         callbacks to see if an ad was successfully retrieved. 
 */
private PluginResult executeRequestAd(JSONArray inputs) {
  boolean isTesting;
  JSONObject inputExtras;

  // Get the input data.
  try {
    isTesting = inputs.getBoolean( IS_TESTING_ARG_INDEX );
    inputExtras = inputs.getJSONObject( EXTRAS_ARG_INDEX );

  } catch (JSONException exception) {
    Log.w(LOGTAG, String.format("Got JSON Exception: %s", exception.getMessage()));
    return new PluginResult(Status.JSON_EXCEPTION);
  }

  // Request an ad on the UI thread.
  return executeRunnable(new RequestAdRunnable(isTesting, inputExtras));
}
 
开发者ID:psydrake,项目名称:litecoinEasyCheck,代码行数:28,代码来源:AdMob.java

示例4: speak

private PluginResult speak(JSONArray data, CallbackContext callbackContext){// String callbackId) {

		try {
			
			String text = data.getString(0);
			boolean isSsml = data.getBoolean(2);
			
			String voice = null;
			if(data.length() > 3){
				voice = data.getString(3);
			}
			
			NuanceEngine.getInstance().setVoice(voice);
			NuanceEngine.getInstance().speak(text, isSsml, createVocalizerHandler(callbackContext));
			
			PluginResult result;
			if(callbackContext != null){
				result = new PluginResult(Status.NO_RESULT);
				result.setKeepCallback(true);
			}
			else {
				result = new PluginResult(Status.OK);
			}
			
			return result;
		} catch (JSONException e) {
			LOG.e(PLUGIN_NAME, "Failed to synthesize text!", e);
			return new PluginResult(Status.JSON_EXCEPTION, "Failed to synthesize text!");
		}

	}
 
开发者ID:mmig,项目名称:mmir-plugin-speech-nuance,代码行数:31,代码来源:NuanceSpeechPlugin.java

示例5: executeConnectWifi

private PluginResult executeConnectWifi(JSONArray inputs, CallbackContext callbackContext) {
  	Log.w(LOGTAG, "executeConnectWifi");

boolean toEnable = true;
try {
	toEnable = inputs.getBoolean( 0 );
} catch (JSONException e) {
      Log.w(LOGTAG, String.format("Got JSON Exception: %s", e.getMessage()));
      return new PluginResult(Status.JSON_EXCEPTION);
}

return null;
  }
 
开发者ID:floatinghotpot,项目名称:cordova-plugin-wifi,代码行数:13,代码来源:WifiAdmin.java

示例6: executeEnableWifiAP

private PluginResult executeEnableWifiAP(JSONArray inputs, CallbackContext callbackContext) {
  	Log.w(LOGTAG, "executeEnableWifiAP");

boolean toEnable = true;
try {
	toEnable = inputs.getBoolean( 0 );
} catch (JSONException e) {
      Log.w(LOGTAG, String.format("Got JSON Exception: %s", e.getMessage()));
      return new PluginResult(Status.JSON_EXCEPTION);
}

return null;
  }
 
开发者ID:floatinghotpot,项目名称:cordova-plugin-wifi,代码行数:13,代码来源:WifiAdmin.java

示例7: executeEnableWifiLock

private PluginResult executeEnableWifiLock(JSONArray inputs, CallbackContext callbackContext) {
  	Log.w(LOGTAG, "executeEnableWifiLock");

boolean toEnable = true;
try {
	toEnable = inputs.getBoolean( 0 );
} catch (JSONException e) {
      Log.w(LOGTAG, String.format("Got JSON Exception: %s", e.getMessage()));
      return new PluginResult(Status.JSON_EXCEPTION);
}

Context context = cordova.getActivity().getApplicationContext();
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

if(wifiLock == null) {
	wifiLock = wifiManager.createWifiLock("Test");
}

if(wifiLock != null) {
	if(toEnable) {
		wifiLock.acquire();
	} else {
        if(wifiLock.isHeld()) {
        	wifiLock.release();
        }
	}
}

callbackContext.success();

  	return null;
  }
 
开发者ID:floatinghotpot,项目名称:cordova-plugin-wifi,代码行数:32,代码来源:WifiAdmin.java

示例8: executeShowAd

/**
 * Parses the show ad input parameters and runs the show ad action on
 * the UI thread.
 *
 * @param inputs The JSONArray representing input parameters.  This function
 *        expects the first object in the array to be a JSONObject with the
 *        input parameters.
 * @return A PluginResult representing whether or not an ad was requested
 *         succcessfully.  Listen for onReceiveAd() and onFailedToReceiveAd()
 *         callbacks to see if an ad was successfully retrieved. 
 */
private PluginResult executeShowAd(JSONArray inputs) {
  boolean show;

  // Get the input data.
  try {
      show = inputs.getBoolean( SHOW_AD_ARG_INDEX ); 
  } catch (JSONException exception) {
    Log.w(LOGTAG, String.format("Got JSON Exception: %s", exception.getMessage()));
    return new PluginResult(Status.JSON_EXCEPTION);
  }
  
  // Request an ad on the UI thread.
  return executeRunnable( new ShowAdRunnable(show) );
}
 
开发者ID:psydrake,项目名称:litecoinEasyCheck,代码行数:25,代码来源:AdMob.java

示例9: run

@SuppressWarnings("unchecked")
@Override
public void run() {
  if (adView == null) {
    result = new PluginResult(Status.ERROR, "AdView is null.  Did you call createBannerView?");
  } else {
    AdRequest request = new AdRequest();
    if (isTesting) {
      // This will request test ads on the emulator only.  You can get your
      // hashed device ID from LogCat when making a live request.  Pass
      // this hashed device ID to addTestDevice request test ads on your
      // device.
      request.addTestDevice(AdRequest.TEST_EMULATOR);
    }
    AdMobAdapterExtras extras = new AdMobAdapterExtras();
    Iterator<String> extrasIterator = inputExtras.keys();
    boolean inputValid = true;
    while (extrasIterator.hasNext()) {
      String key = extrasIterator.next();
      try {
        extras.addExtra(key, inputExtras.get(key));
      } catch (JSONException exception) {
        Log.w(LOGTAG, String.format("Caught JSON Exception: %s", exception.getMessage()));
        result = new PluginResult(Status.JSON_EXCEPTION, "Error grabbing extras");
        inputValid = false;
      }
    }
    if (inputValid) {
      extras.addExtra("cordova", 1);
      request.setNetworkExtras(extras);
      adView.loadAd(request);
      result = new PluginResult(Status.OK);
    }
  }
  synchronized (this) {
    this.notify();
  }
}
 
开发者ID:psydrake,项目名称:litecoinEasyCheck,代码行数:38,代码来源:AdMob.java


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