Je règle plusieurs alarmes en répétition via le gestionnaire d'alarmes, elles fonctionnent correctement le jour où elles sont réglées mais ne se répètent pas du tout. J'ai mis à jour mon code mais je ne peux pas attendre toute la journée pour vérifier si le code fonctionne même ou pas alors j'ai essayé la commande d'alarme ADB shell dumpsys mais je ne sais pas lire correctement la sortie et comment extraire les temps d'alarmes en cours de réglage. J'ai suivi quelques liens pour comprendre la sortie, mais aucun ne spécifie comment vérifier l'heure exacte de l'alarme en cours de réglage. voici ma sortie Comment lire la sortie d'alarme Adb Dumpsys
mon code principal où je réglage de l'alarme
final int _id = (int) System.currentTimeMillis();
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
// alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,AllTime[i],AlarmManager.INTERVAL_DAY,
// PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT));
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,AllTime[i],AlarmManager.INTERVAL_DAY,
PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT));
et cela ce récepteur de diffusion
public void onReceive(Context context, Intent intent) {
String[] myStrings = intent.getStringArrayExtra("strings");
Log.i("okk", "cathing intent values through break" + Arrays.toString(myStrings));
createNotification(context, "Time is here baby", "this is the notification text", "Alert");
Log.i("okk", "cathing intent values through break" + Arrays.toString(myStrings));
}
public void createNotification(Context context, String msg, String msgText, String msgAlert) {
final int _id = (int) System.currentTimeMillis(); // unique request code
// will open mainActivity on notification click, can change it
// PendingIntent notificationIntent = PendingIntent.getActivity(context, _id, new Intent(context, MainActivity.class), 0); // changed from 0 to _id
PendingIntent notificationIntent = PendingIntent.getActivity(context,0, new Intent(context,MainActivity.class),0);
NotificationCompat.Builder mbuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.cast_ic_notification_play)
.setContentTitle(msg)
.setTicker(msgAlert)
.setContentText(msgText);
// now intent we want to fire when noti is clicked
mbuilder.setContentIntent(notificationIntent);
// how person is notified
mbuilder.setDefaults(NotificationCompat.DEFAULT_SOUND);
mbuilder.setAutoCancel(true); // noti dismisble when user swipe it away
NotificationManager notificationManager = (NotificationManager)
context.getSystemService((Context.NOTIFICATION_SERVICE));
// Log.i("okk", "NOTIFIED " + intent.getExtras());
notificationManager.notify(1, mbuilder.build()); // changes from 1 to _id
}
envoyer votre code pour savoir comment vous définissez l'alarme – OBX
@OBX juste fait. vérifier –