Search code examples
androidnotificationscrouton

Croutons not showing properly - CroutonQueue somehow stuck?


I'm facing a serious problem with the Croutons Notification Library, When i quickly switch my activites, sometimes (very often indeed) croutons for updates, like missing credentials, or "insert date first" are not shown anymore, and so the users stay without any info, what's the problem.

For instance also the simple usecase: Login To Application, Logout,

try to re-login but with false credentials, doesnt show a crouton anymore.

I tried: Courton.clearAllNotifcations() in inPause(), and additionally, Crouton.clearCroutonsForActivity(this) too in onPause(),

to maybe solve the Problem, but it didn't.

I also debugged in the CroutonLibrary and the problem seems to be, a Crouton gets added to queue, the the activity gets finished, the something finishes (like aSyncTask showing a crouton in onPostExecute(), this one gets added to the queue again, and then the queue is stuck.

Also.clearAllNotifications (which actually clears the queue) doesn't work, because the courton (asynctask finishes after acitvity.finish()) gets added afterwards, and the problem persists.

also tried:

   @Override
    protected void onDestroy() {
         Crouton.clearCroutonsForActivity(this);
         Crouton.cancelAllCroutons();
         super.onDestroy();
     }

knwon issue: https://github.com/keyboardsurfer/Crouton/issues/24 but didn't work too...

Thankful for any advice! :)


Solution

  • thx @keyboardsurfer for the explanation...

    adding... and extracting the AsyncTask to a member variable...

    @Override
        protected void onPause() {
            Crouton.clearCroutonsForActivity(this);
            if (loadTasksTask != null) {
                loadTasksTask.cancel(true);
            }
            super.onPause();
        }
    

    fixed the issue! :) thx a lot :)