Android Services background service case analysis summary

The basic points of the service:
1. Background service
2. No interactive interface, does not follow the life cycle of the interface
3. It has a higher priority than the invisible interface, and the service is often used in situations where audio and video are played.
4. By default, the service and the main thread run in the same program.
Generally, a large number of resource computing tasks in the background are processed asynchronously.
To use the service, it is generally to create a new thread in the service for processing in the background, and then stop the service when the processing is completed.
Services running in the program process are called local services.

Custom service:
1. The service needs to be declared in AndroidManifest.xml, and the implementation class of the service needs to inherit from the Service class or its subclasses

<service
    android:name="MyService"
    android:icon="@drawable/icon"
    android:label="@string/service_name"
    >

Guess you like

Origin blog.csdn.net/poolooloo/article/details/106898175