当我在配置活动中更改刷新时间时,我想在我的服务中重新启动我的 TimerTask。
配置活动更改公共静态长 UPDATE_INTERVAL
你对我有什么想法吗?
public void onStart(Intent intent, int startId) {
// init the service here
try {
if (prefs.getString("oauth_token_secret", null) != null) {
_startService();
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
}
}
private void _startService() {
timer.scheduleAtFixedRate(
new TimerTask() {
public void run() {
//doing things
}
}, 0, UPDATE_INTERVAL);
}
感谢到目前为止。斯特凡