List of usage examples for org.json JSONException printStackTrace
public void printStackTrace()
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Sends delete_user message for currently logged in user. *//*from ww w . java 2s . c o m*/ public void sendDeleteUser() { if (mWSC != null && mUserAuth != null) { try { JSONObject deleteUser = new JSONObject(); deleteUser.put("action", "delete_user"); deleteUser.put("action_id", EVENT_DELETE_USER); deleteUser.put("user_auth", mUserAuth); mWSC.send(deleteUser.toString()); } catch (JSONException ex) { ex.printStackTrace(); } } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send describe_user message. On completion client will be notified via * observer.//from ww w . ja v a2 s .c o m */ public void sendDescribeUser(String userId) { try { JSONObject describeUser = new JSONObject(); describeUser.put("action", "describe_user"); describeUser.put("action_id", EVENT_DESCRIBE_USER); describeUser.put("user_id", userId); mWSC.send(describeUser.toString()); } catch (JSONException ex) { ex.printStackTrace(); } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send join_channel message. On completion client will be notified via on * joined callback./*from ww w . j a v a 2 s.c o m*/ */ public void sendJoinChannel(String channelId) { try { mObserver.onServerMessage(new Message(Message.TYPE_LOG, "Send join channelId=" + channelId)); JSONObject join_channel = new JSONObject(); join_channel.put("action", "join_channel"); join_channel.put("action_id", EVENT_JOIN); join_channel.put("channel_id", channelId); mWSC.send(join_channel.toString()); } catch (JSONException ex) { ex.printStackTrace(); } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send message to channel. On completion client will be notified via on * channel callback./* w w w . ja va 2s.c o m*/ */ public void sendMessageChannel(String channelId, String text) { if (text.length() > 0) { try { JSONObject sendMessage = new JSONObject(); sendMessage.put("action", "send_message"); sendMessage.put("action_id", EVENT_MESSAGE); sendMessage.put("channel_id", channelId); sendMessage.put("message_type", "ninchat.com/text"); sendMessage.put("frames", 1); mWSC.send(sendMessage.toString()); JSONObject message = new JSONObject(); message.put("text", text); mWSC.send(message.toString()); } catch (JSONException ex) { ex.printStackTrace(); } } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send message to user. On completion client will be notified via user * message callback.//from w w w .ja v a 2 s . c om */ public void sendMessageUser(String userId, String text) { if (text.length() > 0) { try { JSONObject sendMessage = new JSONObject(); sendMessage.put("action", "send_message"); sendMessage.put("action_id", EVENT_MESSAGE); sendMessage.put("user_id", userId); sendMessage.put("message_type", "ninchat.com/text"); sendMessage.put("frames", 1); mWSC.send(sendMessage.toString()); JSONObject message = new JSONObject(); message.put("text", text); mWSC.send(message.toString()); } catch (JSONException ex) { ex.printStackTrace(); } } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send part_channel message. Callback will be invoked on completion. *//*from w ww. j ava 2 s . c o m*/ public void sendPartChannel(String channelId) { try { JSONObject partChannel = new JSONObject(); partChannel.put("action", "part_channel"); partChannel.put("action_id", EVENT_PART_CHANNEL); partChannel.put("channel_id", channelId); mWSC.send(partChannel.toString()); } catch (JSONException ex) { ex.printStackTrace(); } }
From source file:fi.harism.lucidchat.api.ChatConnection.java
/** * Send search message. Results will be sent via callback. *//*from w w w . j av a 2s. c o m*/ public void sendSearch(String searchText) { if (searchText.length() > 0) { try { mObserver.onServerMessage(new Message(Message.TYPE_LOG, "Send search \"" + searchText + "\"")); JSONObject search = new JSONObject(); search.put("action", "search"); search.put("action_id", EVENT_SEARCH); search.put("search_term", searchText); mWSC.send(search.toString()); } catch (JSONException ex) { ex.printStackTrace(); } } }
From source file:com.example.m.niceproject.data.Condition.java
@Override public JSONObject toJSON() { JSONObject data = new JSONObject(); try {// w w w .j a v a 2 s . co m data.put("code", code); data.put("temp", temperature); data.put("text", description); } catch (JSONException e) { e.printStackTrace(); } return data; }
From source file:com.ijiaban.uitls.AbstractGetNameTask.java
@Override protected Void doInBackground(Void... params) { try {//from w w w. j a v a 2s .c om fetchNameFromProfileServer(); fetchImageFromProfileServer(); fetchSubsChannelsfrmpprofileServer(); } catch (IOException ex) { onError("Following Error occured, please try again. " + ex.getMessage(), ex); } catch (JSONException e) { onError("Bad response: " + e.getMessage(), e); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:cn.code.notes.gtask.data.TaskList.java
public JSONObject getCreateAction(int actionId) { JSONObject js = new JSONObject(); try {/*from w w w . j ava2 s . co m*/ // action_type js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, GTaskStringUtils.GTASK_JSON_ACTION_TYPE_CREATE); // action_id js.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, actionId); // index js.put(GTaskStringUtils.GTASK_JSON_INDEX, mIndex); // entity_delta JSONObject entity = new JSONObject(); entity.put(GTaskStringUtils.GTASK_JSON_NAME, getName()); entity.put(GTaskStringUtils.GTASK_JSON_CREATOR_ID, "null"); entity.put(GTaskStringUtils.GTASK_JSON_ENTITY_TYPE, GTaskStringUtils.GTASK_JSON_TYPE_GROUP); js.put(GTaskStringUtils.GTASK_JSON_ENTITY_DELTA, entity); } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); throw new ActionFailureException("fail to generate tasklist-create jsonobject"); } return js; }