It is useful to use intent to control Service
The parameter used is the class of the service
There is another way to control the startup/shutdown of a service
Parameters for incoming action via intent
Register a service in manifest and set an action
<service android:enabled= "true" android:exported= "false" Android:name= "Com.services.sev.PlayService" > <intent-filter> <action android:name= "Com.example.codetest_1.action.startPlayService"/ > </intent-filter></service>
Note The string for this name
You can add a field to the service class
public static final String ACTION = "Com.example.codetest_1.action.startPlayService";
This allows you to start/Shut down the service by simply modifying the intent call method.
Intent Intent = new Intent (); Intent.setaction (playservice.action); This.startservice (Intent);
Intent Intent = new Intent (); Intent.setaction (playservice.action); This.stopservice (Intent);
Android development use action to start/close service