Android implements the method of stopping Service from activity
- 2021-01-22 05:23:46
- OfStack
This article shows an example of how Android can be implemented to stop Service from activity. To share with you for your reference, as follows:
1. Register Service with AndroidManifest.xml
<service android:name=".service.SensorService" >
<intent-filter>
<action android:name="ITOP.MOBILE.SIMPLE.SERVICE.SENSORSERVICE"/>
</intent-filter>
</service>
2. Called in Activity
final Intent intent = new Intent();
intent.setAction("ITOP.MOBILE.SIMPLE.SERVICE.SENSORSERVICE");
stopService(intent);
For more information on Android development, please check out the Android Introduction and Advanced Course.
I hope this article is helpful to Android program design.