Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AlarmNotificationReceiver extends BroadcastReceiver{
- private RequestQueue mQueue;
- @Override
- public void onReceive(Context context, Intent intent) {
- mQueue = Volley.newRequestQueue(context);
- while(true){
- if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
- JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, API.getDeviceTypes(), null, new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- try {
- Log.d("mytag","TEST"); //THIS IS NEVER BEING PRINTED!
- processResponse(response);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Log.d("mytag", "Error de response");
- error.printStackTrace();
- }
- });
- mQueue.add(request);
- Log.d("mytag","OK IM HERE EVERYONE"); // THIS WORKS
- }
- try {
- Thread.sleep(60000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment