我注意到Service.START_STICKY
不起作用,當我仔細看看時,我看到onCreate()正在運行,但onStartCommand未被調用。Android服務onStartCommand從來沒有叫
任何想法爲什麼?
@Override
public void onCreate() {
mGlobalData = GlobalData.getInstance();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (mTimer == null)
mTimer = new Timer();
Log.e(TAG, "onCreate()");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int t = START_STICKY;
Log.e(TAG, "call me redundant BABY! onStartCommand service");
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return t;
}
爲我工作。但是,當我從onCreate方法中刪除它以確認這實際上是問題時,問題就消失了。 – Zeezer