本文實(shí)例講述了Android實(shí)現(xiàn)從activity中停止Service的方法。分享給大家供大家參考,具體如下:
1、在AndroidManifest.xml注冊Service
<service android:name=".service.SensorService" > <intent-filter> <action android:name="ITOP.MOBILE.SIMPLE.SERVICE.SENSORSERVICE"/> </intent-filter></service>
2、在Activity中調(diào)用
final Intent intent = new Intent();intent.setAction("ITOP.MOBILE.SIMPLE.SERVICE.SENSORSERVICE");stopService(intent);更多關(guān)于Android開發(fā)相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選