The role of Android's four components and the role of Android service

Source: Internet
Author: User

Activity appears to be an application's eye, providing a window of interaction with the user.

Broadcastreceiver seemed to be ears, receiving intent from all sides.

The service is running in the background.

A service is a section of a life cycle, without a user-interface program. A good example of this is the one that is being played from the playlist

The media player that plays the song. In a media player application, there should be multiple activity, allowing the user to select songs and play

Songs. However, there is no activity associated with the music replay function, as users will of course think that music should be used when navigating to other screens

It's still playing. In this example, the Media Player activity uses context.startservice () to start a service, which

You can keep your music playing in the background. At the same time, the system will keep the service running until the end of the service run. Other than that

We can also connect to a service by using the Context.bindservice () method (if the service is not running it will start

IT). When connected to a service, we can also communicate with it by the interface provided by the service. Take the Media Player example, we can also pause, replay and other operations

ContentProvider provides a way to access other application databases or other data.

The role of Android's four components and the role of Android 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.