"Sail Plan 025" 2015 sail plan Android Apidemo Devil steps for App->notification->notifying Service Controller Using Notification in service

Source: Internet
Author: User

This example shows how to use notification in a service, and the related classes are Notifyingcontroller and Notifyingservice.

The basic method of using notification in a service is the same as the previous example. We haven't introduced service usage for the time being. The basic concept of service is basically the same as the service in Windows OS: No UI, run in the background. Notification can be said to be the best way to notify users of the service. There is a special introduction to service usage, which is not explained here.

The Notifyingservice implementation displays a notification every 5 seconds within a minute. The icons are smiley faces, expressionless, crying faces:

             for(inti = 0; I < 4; ++i) {shownotification (R.drawable.stat_happy, R.string.status_bar_notifications_h                Appy_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; }            //Do with our work ... stop the service!Notifyingservice. This. Stopself ();

"Sail Plan 025" 2015 sail plan Android Apidemo Devil steps for App->notification->notifying Service Controller Using Notification in service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.