Connecting Estimote Beacons with Web Service

I’m new to Android and i’m trying to build a android application using Estimote Beacons. i want to get dynamic notifications from web service. for that I’ve added network call in Android application class so that it could call continuously in background. Problem i’m facing is sometimes the network call triggers and sometimes it won’t. Is it the rite thing to make network calls from Application class.? How do i go about this.?`Below i have attached the Application class code.

        public class AppController extends Application {
    public static final String TAG = AppController.class.getSimpleName();
    private boolean beaconNotificationsEnabled = false;
    SharedPreferences sharedPreferences;
    Editor editor;
    private RequestQueue mRequestQueue;
    String uuid_beacon;
    String displayNotification;
    private BeaconManager beaconManager;
    private static AppController mInstance;

    String authLoginValue;
    String displayMinorNO;
    String uuid;
    String majorno;
    String minorno;
    String notify;
    String urlforimage;

    public void onCreate() {

        sharedPreferences = getApplicationContext().getSharedPreferences("Reg", 0);
        editor = sharedPreferences.edit();
        mInstance = this;
        authLoginValue = sharedPreferences.getString("AuthTokenLogin", "");
        System.out.println("LOGIN FROM APP CONTROLLER:"+authLoginValue);

        beaconManager = new BeaconManager(getApplicationContext());
        beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
            public void onEnteredRegion(Region region, List<Beacon> list) {

                for (Beacon beacon : list) {
                    uuid = beacon.getProximityUUID().toString();
                    majorno = String.valueOf(beacon.getMajor());
                    minorno = String.valueOf(beacon.getMinor());
                    sendUUID(uuid, authLoginValue, majorno, minorno);

                displayNotification = sharedPreferences.getString("Notification", "");

                showNotification(displayNotification, "Click here to continue");
            public void onExitedRegion(Region region) {
                // could add an "exit" notification too if you want (-:
                        "THANKS FOR VISITING",
                        "Come back again"
        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            public void onServiceReady() {
                beaconManager.startMonitoring(new Region("monitored region",
                        UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null));

    public static synchronized AppController getInstance() {
        return mInstance;
    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());

        return mRequestQueue;

    public <T> void addToRequestQueue(Request<T> req, String tag) {
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);

    public <T> void addToRequestQueue(Request<T> req) {

    public void cancelPendingRequests(Object tag) {
        if (mRequestQueue != null) {

    public void showNotification(String title, String message) {
        Intent notifyIntent = new Intent(this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivities(this, 0,
                new Intent[]{notifyIntent}, PendingIntent.FLAG_UPDATE_CURRENT);
        Notification notification = new Notification.Builder(this)
        notification.defaults |= Notification.DEFAULT_SOUND;
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, notification);

    public void sendUUID(final String uuid, final String authTokenLoginValue,final String majorno, final String minorno) {

        // Tag used to cancel the request
        String tag_string_req = "req_register";

        StringRequest strReq = new StringRequest(Request.Method.POST,
                AppConfig.URL_UUID, new Response.Listener<String>() {

            public void onResponse(String response) {
                Log.d(TAG, "Notification Response: " + response.toString());
                try {
                    JSONObject jObj = new JSONObject(response);
                    String notifyresponse = jObj.getString("notification");

                    JSONObject objecttonotify = new JSONObject(notifyresponse);

                    notify = objecttonotify.getString("notification");
                    urlforimage = objecttonotify.getString("url");


                    editor.putString("Notification", notify);
                    editor.putString("image_url", urlforimage);

                    Log.d(TAG, "Notification1" + notify);

                    String msg =jObj.get("status").toString();

                        String SuccessMsg = jObj.getString("message");
                        //Toast.makeText(getApplicationContext(), SuccessMsg, Toast.LENGTH_LONG).show();
                    else if(msg.equals("error")) {
                        String errorMsg = jObj.getString("message");
                        Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
                } catch (JSONException e) {

        }, new Response.ErrorListener() {

            public void onErrorResponse(VolleyError error) {
                Log.e(TAG, "Notification Error: " + error.getMessage());
                        error.getMessage(), Toast.LENGTH_LONG).show();

        }) {

            protected Map<String, String> getParams() {
                // Posting params to register url
                Map<String, String> params = new HashMap<String, String>();
                params.put("uuid", uuid);
                params.put("authtoken", authTokenLoginValue);
                params.put("major_no", majorno);
                params.put("minor_no", minorno);

                return params;


        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(strReq, tag_string_req);

Can you try providing a Minimal, Complete, and Verifiable example? It’s very hard to try to reproduce your problem with the code you’ve given.