欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android Service自啟動注意事項(xiàng)分析

 更新時間:2016年03月09日 10:45:53   作者:nosxcy  
這篇文章主要介紹了Android Service自啟動注意事項(xiàng),結(jié)合實(shí)例分析了Android Service自啟動過程中屬性設(shè)置的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例分析了Android Service自啟動注意事項(xiàng)。分享給大家供大家參考,具體如下:

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    if(intent == null)
      return;
}
@Override
public void onDestroy() {
    super.onDestroy();
    Intent intent = new Intent(SensorService.this, SensorService.class);
    startService(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//    flags = Service.START_STICKY;
    flags = Service.START_REDELIVER_INTENT;
    return super.onStartCommand(intent, flags, startId);
}

PS重點(diǎn)就在這個 flags ,開始時用Service.START_STICKY; Service 經(jīng)常會自動FC查了好久才發(fā)現(xiàn)再次自啟動時候onStart里intent為null,改為flags = Service.START_REDELIVER_INTENT;就可以了。

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android調(diào)試技巧與常見問題解決方法匯總》、《Android開發(fā)入門與進(jìn)階教程》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論