Android 使用alarm更改应用程序的颜色
我想在我的android应用程序运行到凌晨12点时(即当天变化),立即更改所有按钮和布局的颜色和背景 我应该能够做到这一点,使用报警,每当报警给出反馈 或者我调用一个函数,它应该改变颜色和背景,但它不工作Android 使用alarm更改应用程序的颜色,android,Android,我想在我的android应用程序运行到凌晨12点时(即当天变化),立即更改所有按钮和布局的颜色和背景 我应该能够做到这一点,使用报警,每当报警给出反馈 或者我调用一个函数,它应该改变颜色和背景,但它不工作 Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 15); calendar.set(Calendar.MINUTE, 53); calendar.set
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 15);
calendar.set(Calendar.MINUTE, 53);
calendar.set(Calendar.SECOND, 0);
AlarmManager am = (AlarmManager) getApplicationContext()
.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(),
0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
btn.setBackgroundColor(color.blue);
rlbase.setBackgroundColor(color.green);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY , pi);
现在我只改变这些按钮的颜色和背景,但我打算从这个警报调用一个方法
需要帮忙吗
谢谢见此:
它可能对你有用。
祝你好运 你能写下你的密码吗?到目前为止你都试过了什么…?如果有人能告诉我,无论什么时候天变了,或者是24小时00:00,如何更改活动的背景。谢谢,但我相信我不需要广播接收器来更改活动的背景,如果用户在凌晨12点使用该应用程序,则应该对其进行更改,否则将在活动开始时以更改的背景打开该应用程序