List of usage examples for org.json JSONArray getString
public String getString(int index) throws JSONException
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Add tags to a device/* ww w. ja v a 2 s . co m*/ * @param args * @param callbackContext */ protected void addDeviceTags(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "ADDTAGS"); ArrayList<String> tagList = new ArrayList<String>(); try { JSONArray tags = args.getJSONArray(0); if (tags != null) { for (int i = 0; i < tags.length(); i++) { tagList.add(tags.getString(i)); } } Notificare.shared().addDeviceTags(tagList, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Remove tag from a device/*from ww w. ja va 2s.c o m*/ * @param args * @param callbackContext */ protected void removeDeviceTag(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "REMOVETAG"); try { String tag = args.getString(0); if (tag != null) { Notificare.shared().removeDeviceTag(tag, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Create a new user account/*from w ww .java 2s . c o m*/ * @param args * @param callbackContext */ protected void createAccount(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "CREATEACCOUNT"); try { String email = args.getString(0); String password = args.getString(1); String userName = null; if (args.length() == 3) { userName = args.optString(2); } Notificare.shared().createAccount(email, password, userName, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Validate user/*from w w w. ja v a 2 s. c o m*/ * @param args * @param callbackContext */ protected void validateUser(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "VALIDATEUSER"); try { String token = args.getString(0); Notificare.shared().validateUser(token, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Send a password reset email/*www . j a v a 2 s . c o m*/ * @param args * @param callbackContext */ protected void sendPassword(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "SENDPASSWORD"); try { String email = args.getString(0); Notificare.shared().sendPassword(email, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Reset password/*w ww .j a va2 s . c o m*/ * @param args * @param callbackContext */ protected void resetPassword(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "RESETPASSWORD"); try { String password = args.getString(0); String token = args.getString(1); Notificare.shared().resetPassword(password, token, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Change password// w w w .ja va 2 s . co m * @param args * @param callbackContext */ protected void changePassword(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "CHANGEPASSWORD"); try { String password = args.getString(0); Notificare.shared().changePassword(password, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Log in user/*from w w w. j ava 2s.c o m*/ * @param args * @param callbackContext */ protected void userLogin(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "USERLOGIN"); try { String username = args.getString(0); String password = args.getString(1); Notificare.shared().userLogin(username, password, new NotificareCallback<Boolean>() { @Override public void onSuccess(Boolean result) { if (callbackContext == null) { return; } callbackContext.success(); } @Override public void onError(NotificareError error) { if (callbackContext == null) { return; } callbackContext.error(error.getLocalizedMessage()); } }); } catch (JSONException e) { callbackContext.error("JSON parse error"); } }
From source file:re.notifica.cordova.NotificarePlugin.java
/** * Log a custom event/*w w w. ja va2 s . c o m*/ * @param args * @param callbackContext */ protected void logCustomEvent(JSONArray args, final CallbackContext callbackContext) { Log.d(TAG, "LOGCUSTOMEVENT"); try { String name = args.getString(0); JSONObject dataJSON = args.getJSONObject(1); Notificare.shared().getEventLogger().logCustomEvent(name, dataJSON); if (callbackContext == null) { return; } callbackContext.success(); } catch (JSONException e) { if (callbackContext == null) { return; } callbackContext.error("JSON parse error"); } }
From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult result = null;/*from w ww. j a va 2 s. com*/ //args.length() //args.getString(0) //args.getString(1) //args.getInt(0) //args.getInt(1) //args.getBoolean(0) //args.getBoolean(1) //JSONObject json = args.optJSONObject(0); //json.optString("adUnit") //json.optString("adUnitFullScreen") //JSONObject inJson = json.optJSONObject("inJson"); if (action.equals("setUp")) { //Activity activity=cordova.getActivity(); //webView // final String adUnit = args.getString(0); Log.d(LOG_TAG, adUnit); final String adUnitFullScreen = args.getString(1); Log.d(LOG_TAG, adUnitFullScreen); final boolean isOverlap = args.getBoolean(2); Log.d(LOG_TAG, isOverlap ? "true" : "false"); final boolean isTest = args.getBoolean(3); Log.d(LOG_TAG, isTest ? "true" : "false"); final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _setUp(adUnit, adUnitFullScreen, isOverlap, isTest); PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); delayedCC.sendPluginResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); //delayedCC.sendPluginResult(pr); } }); return true; } else if (action.equals("preloadBannerAd")) { //Activity activity=cordova.getActivity(); //webView bannerAdPreload = true; bannerViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _preloadBannerAd(); } }); return true; } else if (action.equals("reloadBannerAd")) { //Activity activity=cordova.getActivity(); //webView bannerViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _reloadBannerAd(); } }); return true; } else if (action.equals("showBannerAd")) { Activity activity = cordova.getActivity(); c.a = this.adUnit; com.jaradsindy.adsindy.u a = new com.jaradsindy.adsindy.u(activity); myAdsIndy = new AdsIndy(activity); myAdsIndy.loadAd(); return true; } else if (action.equals("hideBannerAd")) { //Activity activity=cordova.getActivity(); //webView // bannerViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _hideBannerAd(); } }); return true; } else if (action.equals("preloadFullScreenAd")) { //Activity activity=cordova.getActivity(); //webView // fullScreenAdPreload = true; interstitialViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _preloadFullScreenAd(); } }); return true; } else if (action.equals("reloadFullScreenAd")) { //Activity activity=cordova.getActivity(); //webView // if (interstitialView == null) { //PluginResult pr = new PluginResult(PluginResult.Status.OK); //pr.setKeepCallback(true); //callbackContext.sendPluginResult(pr); PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.setKeepCallback(true); callbackContext.sendPluginResult(pr); return true; } fullScreenAdPreload = true; interstitialViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _reloadFullScreenAd(); } }); return true; } else if (action.equals("showFullScreenAd")) { //Activity activity=cordova.getActivity(); //webView // interstitialViewCC = callbackContext; final CallbackContext delayedCC = callbackContext; cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { _showFullScreenAd(); } }); return true; } return false; // Returning false results in a "MethodNotFound" error. }