Hong,
Thanks for pointing out this bug. This also brings up the point that
canceling a notification as this sample does only cancels a specific
notification, not all notifications from a thread.
Cheers,
Justin
Android Team @ Google
On Jun 9, 9:45 am, Hong <[EMAIL PROTECTED]> wrote:
> There's a bug in sample demoAPI - App/Notification/Notifying Service
> Controller.
>
> Once that service starts, if u stop the service before the 4 iterations are
> completed:
> for (int i = 0; i < 4; ++i) {
> showNotification(R.drawable.stat_happy,
>
> R.string.status_bar_notifications_happy_message);
> Thread.sleep(5 * 1000);
> showNotification(R.drawable.stat_neutral,
> R.string.status_bar_notifications_ok_message);
> Thread.sleep(5 * 1000);
> showNotification(R.drawable.stat_sad,
> R.string.status_bar_notifications_sad_message);
> Thread.sleep(5 * 1000);
> }
>
> The NotificationManager clears the status icon briefly, but the thread keeps
> running until it reaches the end of the 4 iterations.
> So you still see the thread runs to complete (changing status bar icons
> every 5 seconds), while the service is already stopped.
> I think this behavior is not the intended/expected behavior. And thus, a
> bug :)
>
> To fix it, make a local boolean variable, and assign the service status, and
> have the run() method check the variable.
> boolean running = true;
>
> in run():
>
> while (running) {
> // showNotification(...)
>
> }
>
> in onDestroy() {
> running = false;
>
> }
>
> thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---