Skip to content Skip to sidebar Skip to footer

Creating A Real Time Notification From Android Service

I am creating an application which shows the notification as soon as I post a new post on wordpress site. Now the notification is generated as soon as I put a post on the wordpre

Solution 1:

You create the requestQueue from a timer, so every 5 seconds. And within your executed code you create always a new request queue. This won't work you should keep the requestQueue as final global variable and create it only once in your constructor.

publicclassNotifierServiceextendsService {
    privatefinal RequestQueue rQueue;

    NotifierService() {
        this.rQueue = Volley.newRequestQueue(this);
    }

    privatevoidsetupNotificationListener() {
        // do your request handling
    }
}

The OutOfMemoryError might occur because you create so many objects which are not correctly garbage collected

Post a Comment for "Creating A Real Time Notification From Android Service"