List of usage examples for org.json JSONException getCause
public Throwable getCause()
From source file:tech.salroid.filmy.tmdb_account.UnMarkingFavorite.java
private void parseUnMarkedResponse(JSONObject response) { if (listener != null) listener.unmarked(position);// w w w . j a va 2s . co m try { int status_code = response.getInt("status_code"); if (status_code == 13) { CustomToast.show(context, "Movie removed from favorite list.", false); } else { CustomToast.show(context, "Can't remove from favorite list.", false); } } catch (JSONException e) { Log.d("webi", e.getCause().toString()); CustomToast.show(context, "Can't remove from favorite list.", false); } }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create a connection message with the passenger's name and connection time * * @return msg string representation of the JSONObject *///from ww w . j a va2 s . c o m public String getConnectionMessage() { Log.d(TAG, ".getConnectionMessage() entered"); JSONObject msg = new JSONObject(); try { msg.put(Constants.NAME, getPassengerName()); msg.put(Constants.CONNECTION_TIME, System.currentTimeMillis()); } catch (JSONException e) { Log.d(TAG, ".getConnectionMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create a pairing message with the passenger's name, latitude and longitude * * @param lat Latitude value/* w w w .j a v a 2s .c o m*/ * @param lon Longitude value * @return msg string representation of the JSONObject */ public String getPairingMessage(double lat, double lon) { Log.d(TAG, ".getPairingMessage() entered"); JSONObject msg = new JSONObject(); try { msg.put(Constants.NAME, getPassengerName()); msg.put(Constants.LONGITUDE, lon); msg.put(Constants.LATITUDE, lat); } catch (JSONException e) { Log.d(TAG, ".getPairingMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create a message with the passenger's photo encoded as base64 string * * @return msg string representation of the JSONObject *///from w w w . ja va 2 s. c om public String getPassengerPhotoMessage() { Log.d(TAG, ".getPassengerPhotoMessage() entered"); PickMeUpApplication app = (PickMeUpApplication) context.getApplicationContext(); Bitmap passengerPhoto = app.getPassengerPhoto(); ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); passengerPhoto.compress(Bitmap.CompressFormat.PNG, 100, byteOutputStream); String passengerPhotoAsBase64String = Base64.encodeToString(byteOutputStream.toByteArray(), Base64.DEFAULT); JSONObject msg = new JSONObject(); try { msg.put(Constants.URL, Constants.BASE64_PHOTO_PREFIX + passengerPhotoAsBase64String); } catch (JSONException e) { Log.d(TAG, ".getPassengerPhotoMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create a chat message/*ww w . j a v a 2 s . c o m*/ * * @param format Message format - Text or Audio can be used * @param data Message data as string * @return msg string representation of the JSONObject */ public String getChatMessage(String format, String data) { Log.d(TAG, ".getChatMessage() entered"); JSONObject msg = new JSONObject(); try { msg.put(Constants.FORMAT, format); msg.put(Constants.DATA, data); } catch (JSONException e) { Log.d(TAG, ".getChatMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create the passenger's location message * * @param lat Latitude value/* w w w .j a va2s . co m*/ * @param lon Longitude value * @return msg string representation of the JSONObject */ public String getLocationMessage(double lat, double lon) { Log.d(TAG, ".getLocationMessage() entered"); JSONObject msg = new JSONObject(); try { msg.put(Constants.LONGITUDE, lon); msg.put(Constants.LATITUDE, lat); } catch (JSONException e) { Log.d(TAG, ".getLocationMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
/** * Method to create the payment message//from w ww .j a v a2s . com * * @param cost of the trip taken * @param tip for the driver * @param rating for the driver * @return msg string representation of the JSONObject */ public String getPaymentMessage(String cost, String tip, String rating) { Log.d(TAG, ".getPaymentMessage() entered"); JSONObject msg = new JSONObject(); try { msg.put(Constants.COST, cost); msg.put(Constants.TIP, tip); msg.put(Constants.RATING, rating); msg.put(Constants.DRIVER_ID, app.getDriverId()); msg.put(Constants.PASSENGER_ID, getPassengerName()); } catch (JSONException e) { Log.d(TAG, ".getPaymentMessage() - Exception caught while generating a JSON object", e.getCause()); } return msg.toString(); }
From source file:com.googlecode.jsfFlex.phaseListener.ArrayServiceRequestDataRetrieverFlusher.java
@Override void retrieveFlushData(FacesContext context, String componentId, String methodToInvoke) throws ServletException, IOException { JSONArray methodResult = null;/*from w w w .j av a2 s .co m*/ try { methodResult = JSONArray.class .cast(invokeResourceMethod(context, componentId, methodToInvoke, null, null)); } catch (Exception methodInvocationException) { throw new ServletException(methodInvocationException); } HttpServletResponse response = HttpServletResponse.class.cast(context.getExternalContext().getResponse()); response.setContentType(XML_CONTENT_TYPE); StringBuilder responseContent = new StringBuilder(); responseContent.append(XML_HEAD); responseContent.append(XML_RESULT_ROOT_START_TAG); try { responseContent.append(JSONConverter.convertJSONArrayToXMLString(methodResult)); } catch (JSONException jsonException) { throw new ServletException(ERROR_CONVERTING_JSON_ARRAY_TO_XML, jsonException.getCause()); } responseContent.append(XML_RESULT_ROOT_END_TAG); _log.info("Flushing content : " + responseContent.toString()); Writer writer = response.getWriter(); writer.write(responseContent.toString()); writer.flush(); }