App->notification->notifying Service Controller
This example describes how to use notification in a service, and the related classes are Notifyingcontroller and Notifyingservice.
The basic method of using notification in service is the same as the previous example. We haven't introduced the usage of the service for the time being. The basic concept of service is essentially the same as in Windows OS: There is no UI to run in the background. Notification can be said to be the best way to inform users of the service. There is a special introduction to the use of the service, here is not explained.
The Notifyingservice implementation displays a notification every 5 seconds in a minute. Icons are smiley faces, expressionless, crying face:
for (int i = 0; i < 4; ++i) {
shownotification (r.drawable.stat_happy,
r.string.status_bar_notifications_ Happy_message);
if (Mcondition.block (5 * 1000)) break
;
Shownotification (r.drawable.stat_neutral,
r.string.status_bar_notifications_ok_message);
if (Mcondition.block (5 * 1000)) break
;
Shownotification (R.drawable.stat_sad,
r.string.status_bar_notifications_sad_message);
if (Mcondition.block (5 * 1000)) break
;