What is the best way to go about running code immediately on system date change?
Currently I am trying to set the wallpaper on a device based on the date. If the date changes, I will set the wallpaper to a new image. My code for getting and setting the wallpaper all works. I am trying to setup an alarm manager but I can't get it to work. How can I make sure my alarm is set to set the wallpaper each time the date changes and immediately.
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent1 = new Intent(context, AlarmReciever.class);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent1, 0);
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, AlarmManager.INTERVAL_DAY,
AlarmManager.INTERVAL_DAY, alarmIntent);
// Execute DownloadImage AsyncTask
new DownloadImage().execute(URL);
try {
WallpaperManager.getInstance(context).setBitmap(bm);
}
catch ( IOException e) {
}
}
}