0

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! :)

4

2 回答 2

1

您在 Crouton 上找到了正确的问题以及负责产生问题的代码部分。

在您的情况下,它与您实际上应该已经被销毁AsyncTask时仍在运行的 which相关联。Activity将长时间运行的行为从面向用户的组件中移出通常是一件好事,即使用服务层。

在那之前取消AsyncTask应该做的伎俩。

于 2013-10-28T08:50:44.077 回答
0

谢谢@keyboardsurfer的解释...

添加... 并将AsyncTask 提取到成员变量...

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

解决了这个问题!:) 多谢 :)

于 2013-10-28T16:54:35.573 回答