Java Code Examples for org.json.JSONException#toString()
The following examples show how to use
org.json.JSONException#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 6 votes |
public String setuserdata(JSONArray args){ try { // Bundle bundle = new Bundle(); this.log("setuserdata", args); Map<String, String> bundle = new HashMap<String, String>(); bundle.put("name", args.getString(0)); bundle.put("username", args.getString(1)); bundle.put("email", args.getString(2)); bundle.put("organization", args.getString(3)); bundle.put("phone", args.getString(4)); bundle.put("picture", args.getString(5)); bundle.put("picturePath", args.getString(6)); bundle.put("gender", args.getString(7)); bundle.put("byear", String.valueOf(args.getInt(8))); Countly.userData.setUserData(bundle); Countly.userData.save(); return "setuserdata success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 2
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 6 votes |
public String updateRemoteConfigForKeysOnly(JSONArray args, final Callback theCallback){ try { this.log("updateRemoteConfigForKeysOnly", args); String[] keysOnly = new String[args.length()]; for (int i = 0, il = args.length(); i < il; i++) { keysOnly[i] = args.getString(i); ; } Countly.sharedInstance().remoteConfig().updateForKeysOnly(keysOnly, new RemoteConfigCallback() { @Override public void callback(String error) { if (error == null) { theCallback.callback("Success"); } else { theCallback.callback("Error: " + error.toString()); } } }); return "updateRemoteConfigForKeysOnly: success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 3
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 6 votes |
public String updateRemoteConfigForKeysOnly(JSONArray args, final Callback theCallback){ try { this.log("updateRemoteConfigForKeysOnly", args); String[] keysOnly = new String[args.length()]; for (int i = 0, il = args.length(); i < il; i++) { keysOnly[i] = args.getString(i); ; } Countly.sharedInstance().remoteConfig().updateForKeysOnly(keysOnly, new RemoteConfigCallback() { @Override public void callback(String error) { if (error == null) { theCallback.callback("Success"); } else { theCallback.callback("Error: " + error.toString()); } } }); return "updateRemoteConfigForKeysOnly: success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 4
Source File: UserLocationData.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
public static UserLocationData fromJsonStr(String s) { UserLocationData userlocationdata = new UserLocationData(); try { JSONObject jsonobject = new JSONObject(Utils.URLDecodeStr(s)); userlocationdata.city = jsonobject.optString("city"); userlocationdata.longitude = jsonobject.optString("longitude"); userlocationdata.latitude = jsonobject.optString("latitude"); } catch (JSONException jsonexception) { jsonexception.toString(); return userlocationdata; } return userlocationdata; }
Example 5
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String removeConsent(JSONArray args){ try { this.log("removeConsent", args); String consent = null; List<String> features = new ArrayList<>(); for (int i = 0; i < args.length(); i++) { consent = args.getString(i); if (consent.equals("sessions")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.sessions}); } if (consent.equals("events")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.events}); } if (consent.equals("views")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.views}); } if (consent.equals("location")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.location}); } if (consent.equals("crashes")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.crashes}); } if (consent.equals("attribution")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.attribution}); } if (consent.equals("users")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.users}); } if (consent.equals("push")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.push}); } if (consent.equals("starRating")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.starRating}); } } return "removeConsent: Success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 6
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String recordView(JSONArray args){ try { this.log("recordView", args); String viewName = args.getString(0); Countly.sharedInstance().views().recordView(viewName); return "View name sent: " + viewName; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 7
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String userData_pushValue(JSONArray args){ try { this.log("userData_pushValue", args); String type = args.getString(0); String pushValue = args.getString(1); Countly.userData.pushValue(type, pushValue); Countly.userData.save(); return "userData_pushValue success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 8
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String pushTokenType(JSONArray args){ try { this.log("pushTokenType", args); String tokenType = args.getString(0); if("2".equals(tokenType)){ pushTokenTypeVariable = Countly.CountlyMessagingMode.TEST; }else{ pushTokenTypeVariable = Countly.CountlyMessagingMode.PRODUCTION; } return "pushTokenType: success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 9
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String giveConsent(JSONArray args){ try { this.log("giveConsent", args); String consent = null; List<String> features = new ArrayList<>(); for (int i = 0; i < args.length(); i++) { consent = args.getString(i); if (consent.equals("sessions")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.sessions}); } if (consent.equals("events")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.events}); } if (consent.equals("views")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.views}); } if (consent.equals("location")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.location}); } if (consent.equals("crashes")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.crashes}); } if (consent.equals("attribution")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.attribution}); } if (consent.equals("users")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.users}); } if (consent.equals("push")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.push}); } if (consent.equals("starRating")) { Countly.sharedInstance().consent().giveConsent(new String[]{Countly.CountlyFeatureNames.starRating}); } } return "giveConsent: Success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 10
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String recordView(JSONArray args){ try { this.log("recordView", args); String viewName = args.getString(0); Countly.sharedInstance().views().recordView(viewName); return "View name sent: " + viewName; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 11
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String userData_increment(JSONArray args){ try { this.log("userData_increment", args); String keyName = args.getString(0); Countly.userData.increment(keyName); Countly.userData.save(); return "userData_increment: success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 12
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String userData_incrementBy(JSONArray args){ try { this.log("userData_incrementBy", args); String keyName = args.getString(0); int keyIncrement = Integer.parseInt(args.getString(1)); Countly.userData.incrementBy(keyName, keyIncrement); Countly.userData.save(); return "userData_incrementBy success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 13
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String userData_setOnce(JSONArray args){ try { this.log("userData_setOnce", args); String keyName = args.getString(0); String minScore = args.getString(1); Countly.userData.setOnce(keyName, minScore); Countly.userData.save(); return "userData_setOnce success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 14
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String logException(JSONArray args){ try { this.log("logException", args); String exceptionString = args.getString(0); Exception exception = new Exception(exceptionString); Countly.sharedInstance().crashes().recordHandledException(exception); return "logException success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 15
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String getRemoteConfigValueForKey(JSONArray args){ try { this.log("getRemoteConfigValueForKey", args); String getRemoteConfigValueForKeyResult = Countly.sharedInstance().remoteConfig().getValueForKey(args.getString(0)).toString(); return getRemoteConfigValueForKeyResult; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 16
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String changeDeviceId(JSONArray args){ try { this.log("changeDeviceId", args); String newDeviceID = args.getString(0); String onServerString = args.getString(1); if ("1".equals(onServerString)) { Countly.sharedInstance().changeDeviceId(newDeviceID); } else { Countly.sharedInstance().changeDeviceId(DeviceId.Type.DEVELOPER_SUPPLIED, newDeviceID); } return "changeDeviceId success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 17
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String removeConsent(JSONArray args){ try { this.log("removeConsent", args); String consent = null; List<String> features = new ArrayList<>(); for (int i = 0; i < args.length(); i++) { consent = args.getString(i); if (consent.equals("sessions")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.sessions}); } if (consent.equals("events")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.events}); } if (consent.equals("views")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.views}); } if (consent.equals("location")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.location}); } if (consent.equals("crashes")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.crashes}); } if (consent.equals("attribution")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.attribution}); } if (consent.equals("users")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.users}); } if (consent.equals("push")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.push}); } if (consent.equals("starRating")) { Countly.sharedInstance().consent().removeConsent(new String[]{Countly.CountlyFeatureNames.starRating}); } } return "removeConsent: Success"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 18
Source File: CountlyNative.java From countly-sdk-cordova with MIT License | 5 votes |
public String userData_saveMax(JSONArray args){ try { this.log("userData_saveMax", args); String keyName = args.getString(0); int maxScore = Integer.parseInt(args.getString(1)); Countly.userData.saveMax(keyName, maxScore); Countly.userData.save(); return "userData_saveMax success!"; }catch (JSONException jsonException){ return jsonException.toString(); } }
Example 19
Source File: BookResultInfoRetriever.java From android-apps with MIT License | 4 votes |
@Override void retrieveSupplementalInfo() throws IOException, InterruptedException { String contents = HttpHelper.downloadViaHttp("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return; } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e.toString()); } Collection<String> newTexts = new ArrayList<String>(); if (title != null && title.length() > 0) { newTexts.add(title); } if (authors != null && !authors.isEmpty()) { boolean first = true; StringBuilder authorsText = new StringBuilder(); for (String author : authors) { if (first) { first = false; } else { authorsText.append(", "); } authorsText.append(author); } newTexts.add(authorsText.toString()); } if (pages != null && pages.length() > 0) { newTexts.add(pages + "pp."); } String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
Example 20
Source File: SpeedtestConfig.java From speedtest-android with GNU Lesser General Public License v3.0 | 4 votes |
public SpeedtestConfig(JSONObject json){ try { if (json.has("dl_ckSize")) this.dl_ckSize = json.getInt("dl_ckSize"); if (json.has("ul_ckSize")) this.ul_ckSize = json.getInt("ul_ckSize"); if (json.has("dl_parallelStreams")) this.dl_parallelStreams = json.getInt("dl_parallelStreams"); if (json.has("ul_parallelStreams")) this.ul_parallelStreams = json.getInt("ul_parallelStreams"); if (json.has("dl_streamDelay")) this.dl_streamDelay = json.getInt("dl_streamDelay"); if (json.has("ul_streamDelay")) this.ul_streamDelay = json.getInt("ul_streamDelay"); if (json.has("dl_graceTime")) this.dl_graceTime = json.getDouble("dl_graceTime"); if (json.has("ul_graceTime")) this.ul_graceTime = json.getDouble("ul_graceTime"); if (json.has("dl_connectTimeout")) this.dl_connectTimeout = json.getInt("dl_connectTimeout"); if (json.has("ul_connectTimeout")) this.ul_connectTimeout = json.getInt("ul_connectTimeout"); if (json.has("ping_connectTimeout")) this.ping_connectTimeout = json.getInt("ping_connectTimeout"); if (json.has("dl_soTimeout")) this.dl_soTimeout = json.getInt("dl_soTimeout"); if (json.has("ul_soTimeout")) this.ul_soTimeout = json.getInt("ul_soTimeout"); if (json.has("ping_soTimeout")) this.ping_soTimeout = json.getInt("ping_soTimeout"); if (json.has("dl_recvBuffer")) this.dl_recvBuffer = json.getInt("dl_recvBuffer"); if (json.has("ul_recvBuffer")) this.ul_recvBuffer = json.getInt("ul_recvBuffer"); if (json.has("ping_recvBuffer")) this.ping_recvBuffer = json.getInt("ping_recvBuffer"); if (json.has("dl_sendBuffer")) this.dl_sendBuffer = json.getInt("dl_sendBuffer"); if (json.has("ul_sendBuffer")) this.ul_sendBuffer = json.getInt("ul_sendBuffer"); if (json.has("ping_sendBuffer")) this.ping_sendBuffer = json.getInt("ping_sendBuffer"); if (json.has("errorHandlingMode")) this.errorHandlingMode = json.getString("errorHandlingMode"); if (json.has("time_dl_max")) this.time_dl_max = json.getInt("time_dl_max"); if (json.has("time_ul_max")) this.time_ul_max = json.getInt("time_ul_max"); if (json.has("count_ping")) this.count_ping = json.getInt("count_ping"); if (json.has("telemetry_extra")) this.telemetry_extra = json.getString("telemetry_extra"); if (json.has("overheadCompensationFactor")) this.overheadCompensationFactor = json.getDouble("overheadCompensationFactor"); if (json.has("getIP_isp")) this.getIP_isp = json.getBoolean("getIP_isp"); if (json.has("getIP_distance")) this.getIP_distance = json.getString("getIP_distance"); if (json.has("test_order")) this.test_order = json.getString("test_order"); if (json.has("useMebibits")) this.useMebibits = json.getBoolean("useMebibits"); check(); }catch(JSONException t){ throw new IllegalArgumentException("Invalid JSON ("+t.toString()+")"); } }