I have a method that, with AlarmManager, on the 1st of each month should execute a code, but it executes it every time I open the application. It simply adds an entry to a database. I have this method:
public void crack(Context context){
// Establecemos el calendario.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.DAY_OF_MONTH, 1);
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, ReceptorCrack.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, i, 0);
manager.set(AlarmManager.RTC, cal.getTimeInMillis(), pendingIntent);
}