Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JSONObject obj = new JSONObject(result);
- if (obj.getString("status").equals("success")) {
- JSONArray arr = obj.getJSONArray("response");
- UserNotificationTime jour;
- for (int i = 0; i < arr.length(); i++) {
- obj = arr.getJSONObject(i);
- jour = new UserNotificationTime();
- jour.set_breakfast_time(obj.getString("breakfast_time"));
- j_pref_bkTime = jour.get_breakfast_time();
- j_editor.putString("j_bktime", j_pref_bkTime);
- j_editor.commit();
- }
- } else {
- Toast.makeText(getApplicationContext(),
- obj.getString("response"), Toast.LENGTH_SHORT)
- .show();
- }
- j_pref_bkTime = prefs.getString("j_bktime", "OFF"); // get json time from the shared preference
- int hours = new Time(System.currentTimeMillis()).getHours();
- int minute = new Time(System.currentTimeMillis()).getMinutes();
- String time = hours + ":" + minute;
- // splits json time (hour and minute to comapare with current time)
- StringTokenizer tokens_bk = new StringTokenizer(j_pref_bkTime,
- ":");
- String first_bk = tokens_bk.nextToken();
- String second_bk = tokens_bk.nextToken();
- String final_bktime = first_bk.trim() + ":" + second_bk.trim();
- if (time.trim().equals(final_bktime.trim())) {
- // perform some action here but it call when our app open and do some
- into this but i want to call this code also when application is
- close or open means how to compare this code-condition to call
- any time this body when current time match to json time.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement