我必须在UI上5秒后更新数据。我正在使用Alarm Manager但不知道在UI上显示数据。
AlarmReceiver:
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "alarm", Toast.LENGTH_LONG).show();
}
从主要活动中调用:
Intent intentAlarm = new Intent(this, AlarmReceiver.class);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getBroadcast(MainActivity.this, 0,
intentAlarm, 0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), 2000, pi);