@Override protected Boolean doInBackground(Integer... params) { Boolean bool = false; try { UserData.setMemberUsername(context, "gen"); UserData.setSessionId(context, "MTMyODA2NDYwOTM1MDI4NTIxMzU0MjQ2"); String parameter = new String( // "username="******"&" + // "session=" + UserData.getSessionId(context) + "&" + "username="******"gen" + "&" + "session=" + "MTMyODA2NDYwOTM1MDI4NTIxMzU0MjQ2" + "&" + "mode=" + "apply" + "&" + "locationid=" + id); JMCFunction.setDebugLogI(context, "parameter: " + parameter); String json = JMCFunction.getJsonData(context, NearByApi.registerAPI, parameter); JSONObject jsonObject = new JSONObject(json); JSONArray array = jsonObject.optJSONArray("register"); int size = array.length(); for (int i = 0; i < size; i++) { JMCFunction.setDebugLogI( context, array.optJSONObject(i).optString("process") + " " + array.optJSONObject(i).optString("message")); if (array.optJSONObject(i).optString("process").equals(false)) { bool = false; } else { bool = true; } } } catch (JSONException e) { e.printStackTrace(); } return bool; }
@Override protected void onPostExecute(final Boolean bool) { if (bool.equals(Boolean.TRUE)) { JMCFunction.setDebugLogI(context, "Registered!!"); } else { Toast.makeText(context, getString(R.string.connection_error), Toast.LENGTH_LONG).show(); } }