Can't dismiss Android Notification (sometimes)

DaveCarsonDaveCarson GBUniversity ✭✭✭

I have an Android application which performs a scheduled update in the background a number of times a day. During the update there is an ongoing notification displayed which the user cannot dismiss as the notification is configured with SetOngoing(true).

When the process completes the notification displays the update results and this is configured with SetOngoing(false) so the user should be able to dismiss it.

However, I've had reports that sometimes users are finding that the notification will not dismiss and they either have to tap it (which takes them to an activity within the app) or Force Stop the application. I've now experienced this myself so I know it's not a user issue ;-)

I'm using the NoticiationCompat library and the final notification is configured as below:

_nBuilder.SetContentTitle("Update Complete") .SetAutoCancel(true) .SetContentIntent(pendingLogIntent) .SetProgress(0, 0, false) .SetContentText(string.Format("{0} Added, {1} Updated, {2} Deleted", addedCount, updatedCount, deletedCount)) .SetOngoing(false);
Any ideas why this notification will not dismiss?

Thanks in advance

Posts

  • CheesebaronCheesebaron DKInsider, University mod

    What Id are you using for the NotificationManager? Are you using the same for all these notifications?

  • DaveCarsonDaveCarson GBUniversity ✭✭✭

    Yes - the notification id is set as a constant and used each time the notification is displayed - as below:

    nManager.Notify(notificationId, _nBuilder.Build());

  • CheesebaronCheesebaron DKInsider, University mod

    The NotificationManager and NotificationBuilder you are using, are they the compat ones? If not, have you tried using them instead?

  • DaveCarsonDaveCarson GBUniversity ✭✭✭
    edited March 2015

    Yes and no - I've just checked before posting and I see that while I'm using the NotificationCompat library I appear to be using the 'standard' NotificationManager (see below).

    private NotificationManager _nManager; private NotificationCompat.Builder _nBuilder;

    I don't have access to the development environment at the moment (code snippets coming from Github) so I'll check this out later and post back.

    Thanks for the pointer - I added the NotificationCompat library so that notifications were generated for API 14 devices, which they are. Didn't consider the using the Compat version NotificationManager

  • CheesebaronCheesebaron DKInsider, University mod

    I am keen to hear, whether that solves the problem.

  • DaveCarsonDaveCarson GBUniversity ✭✭✭

    That didn't solve the problem I'm afraid - although it has been suggested that this only occurs when the update is triggered via an Alarm (i.e. scheduled). Forcing the refresh from within the application results in "swipe-able" notifications.

Sign In or Register to comment.