谁能告诉我为什么在 android.developer 文档中他们说:just sleep for 30 seconds.
然后放 15 * 1000,这不是 30 秒,它只有 15 !
Runnable mTask = new Runnable() {
public void run() {
// Normally we would do some work here... for our sample, we will
// just sleep for 30 seconds.
long endTime = System.currentTimeMillis() + 15*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (mBinder) {
try {
mBinder.wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
// Done with our work... stop the service!
MyAlarmService.this.stopSelf();
}
};