In my project I want to change a flag value in SharedPreference in particular time every day ,I have implemented the AlarmManager but It is not performing the task . My function to call my receiver class :
public void changeAttendaceFlag(){
Log.d(TAG,"changeAttendaceFlag !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,14);
calendar.set(Calendar.MINUTE,23);
calendar.set(Calendar.SECOND,10);
Intent activateLogin = new Intent(getApplicationContext(),Attendance.class);
PendingIntent pendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),101,activateLogin,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY,pendingIntent);
}
My receiver class :
public class Attendance extends BroadcastReceiver {
FcmSession fcmSession;
private static final String TAG = "Attendance";
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, " Attendance Called !!!!!!!!!!!!!!!!!!!!", Toast.LENGTH_SHORT).show();
fcmSession = new FcmSession(context);
fcmSession.store_dialog_value(true);
UtilsMethods utilsMethods = new UtilsMethods();
String time = utilsMethods.getCurrentDateAndTime();
Log.d(TAG,"change attendance flag :"+time);
}
}