我想制作一个通知应用程序,该应用程序将根据我已完成正在通知的应用程序的数据库中的数据发出警报,我希望它每一小时一次,但通知不超过另一个触发前一个小时。这是代码
Runnable myRunnable = new Runnable(){
@Override
public void run() {
while(true){
try {
runOnUiThread(new Runnable(){
@Override
public void run() {
AsyncDataClass asyncRequestObject = new AsyncDataClass();
asyncRequestObject.execute(serverUrl, email, day, hourToPass);
}
});
counter++;
Thread.sleep(3600000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
Here is the trigger code
PendingIntent pendingIntent = PendingIntent.getBroadcast(LoginActivity.this, 0, alarmIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 3600000, pendingIntent);
正在执行 AsyncTask 的 PostExcute
Runnable myRunnable = new Runnable(){
int counter = 0;
@Override
public void run() {
while(true){
try {
runOnUiThread(new Runnable(){
@Override
public void run() {
AsyncDataClass asyncRequestObject = new AsyncDataClass();
asyncRequestObject.execute(serverUrl, email, day, hourToPass);
}
});
counter++;
Thread.sleep(3600000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
狐的传说
开满天机
相关分类