Creating a real time notification from android service

admin

Administrator
Staff member
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 wordpress site.

But after 40-45 minutes the app gets crashed and gets killed in the background with the following error:-

<a href=" " rel="nofollow noreferrer">the error that showed after the app crashes</a>

I have tried many solutions none of it worked.<br>
I don't want to use
Code:
firebase
for the notification.

I have to fetch the data in real time from the wordpress and then create the notification.

This is the following code for generating the notification:-

private void setupNotificationListener(){

Code:
    StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener&lt;String&gt;() {
        @Override
        public void onResponse(String s) {
            flag=1;
            //System.out.println(flag);
            gson = new Gson();
            list = (List) gson.fromJson(s, List.class);
            postTitle = new String[list.size()];
            postContent=new String[list.size()];

            System.out.println("shiv class:"+list.size());
            for(int i=0;i&lt;list.size();++i) {
                mapPost = (Map&lt;String, Object&gt;) list.get(i);
                mapTitle = (Map&lt;String, Object&gt;) mapPost.get("title");
                postTitle[i] = (String) mapTitle.get("rendered");
                mapContent = (Map&lt;String, Object&gt;) mapPost.get("content");
                postContent[i] = (String) mapContent.get("rendered");
            }
            if(!alreadyNotified(postTitle[0])){
                Log.d("not notified","");
                createNotif(postContent[0],postTitle[0]);
                saveNotificationKey(postTitle[0]);
            }else{
                System.out.print("already notified");
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            Log.d("Error","Error");
        }
    });

    rQueue = Volley.newRequestQueue(NotifierService.this);
    rQueue.add(request);
    NotifierService.getInstance().getRequestQueue().getCache().clear();
}