Guest User

Untitled

a guest
Jun 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public class AlarmNotificationReceiver extends BroadcastReceiver{
  2. private RequestQueue mQueue;
  3.  
  4. @Override
  5. public void onReceive(Context context, Intent intent) {
  6. mQueue = Volley.newRequestQueue(context);
  7. while(true){
  8. if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
  9.  
  10.  
  11. JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, API.getDeviceTypes(), null, new Response.Listener<JSONObject>() {
  12. @Override
  13. public void onResponse(JSONObject response) {
  14. try {
  15. Log.d("mytag","TEST"); //THIS IS NEVER BEING PRINTED!
  16. processResponse(response);
  17. } catch (JSONException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. }, new Response.ErrorListener() {
  22. @Override
  23. public void onErrorResponse(VolleyError error) {
  24. Log.d("mytag", "Error de response");
  25. error.printStackTrace();
  26. }
  27. });
  28.  
  29. mQueue.add(request);
  30. Log.d("mytag","OK IM HERE EVERYONE"); // THIS WORKS
  31.  
  32. }
  33. try {
  34. Thread.sleep(60000);
  35. } catch (InterruptedException e) {
  36. e.printStackTrace();
  37. }
  38. }
  39.  
  40. }
Add Comment
Please, Sign In to add comment