哪位高手帮忙指导一下这个该怎么弄, 。
35
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); intent2 = new Intent("Action.Alarm"); pi = PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() ,System.currentTimeMillis()+30*60*1000,pi);
15
/**
* 刷新数据:获取实时里程;
* 10秒钟刷新一次;
*/
private void Refresh() {
if (refreshTimeTask == null) {
LogUtil.e(TAG,”定时器线程 refreshTimeTask == null ************* 重新 new********************”);
refreshTimeTask = new TimerTask() {
@Override
public void run() {
LogUtil.e(TAG,”定时器线程 ***************************************”);
}
//此处获取服务器数据
Message msg = new Message();
msg = new Message();
msg.what = 1;
mHandler.sendMessage(msg);
}
};
}
if (mTimer == null) { //当前里程的
LogUtil.e(TAG,”定时器线程 mTimer == null ************* 重新 new********************”);
mTimer = new Timer();
mTimer.schedule(refreshTimeTask, 1*1000, 10 * 1000);
LogUtil.e(TAG,”启动定时器 ******************* ****************************”);
}else{
}
}
/**
* 定时器线程
*/
private TimerTask refreshTimeTask = new TimerTask() {
@Override
public void run() {
LogUtil.e(TAG,”定时器线程 ************* 获取里程 **************************”);
if (!MonitorService.isRunning || !isRefresh) {
return;
}
//此处获取服务器数据
Message msg = new Message();
msg = new Message();
msg.what = 1;
mHandler.sendMessage(msg);
}
};
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 1:
LogUtil.i(TAG, “***********************”);
LogUtil.e(TAG,”定时器 mHandler 1 ***********************************************”);
}
break;
}
}}