"Turn" Pro Android Learning Note (76): Service (1): Local and remote

Source: Internet
Author: User

The articles reproduced can only be used for non-commercial nature, and can not be accompanied by virtual currency, points, registration and other additional conditions. Reprint must indicate the source: http://blog.csdn.net/flowingflying/

Android provides services, services are components running in the background, no UI, independent of the activity's life cycle. There are two types of services: local services and remote services. A local service can only be called by this application, and the remote service may be called by another application. The remote service is described by Aidl (Android Interface Definition Language). This section of the service focuses on remote services, and local services will be further studied in the future.

There are three good posts in the Android Learning Note series about services: Android learning Note (51): Service Services (top)-intentservice, Android learning Note (52): Service Services (Medium)- Inherit the service class and the Android learning Note (53): Services (under)-Remote service.

Android provides service concepts for two reasons: 1, easier to implement background tasks, 2, inter-process communication (IPC) between applications. The former corresponds to the local service, which corresponds to the remote service.

The Android.app.Service class provided by Android is different from the asynctask that you just learned, and the service class does not have a thread, that is, if we do not create a thread for it, the service will run in the main thread.

For local service, which is limited to components used on the same thread, the client starts the service through Context.startservice (). If the service supports Onbind (), it indicates that it is a remote service that is invoked through interprocess communication Context.bindservice (), and can be communicated to the service through AIDL because of the remote service support AIDL. Although the service class supports both local and remote two, we should not create a service object that supports both, because they have different pre-defined lifecycles and don't confuse them.

Remote service also has many names, such as RPC (remote Procedure Call) service, Aidl service.

This should be a new record of the shortest length of the series.

RELATED Links: My Android development related articles

"Turn" Pro Android Learning Note (76): Service (1): Local and remote

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.