0

I'm setting multiple alarms on repeat through alarm manager. all are working fine for the day i'm setting them but none of it is getting repeat. here is my broadcast receiver.

    public class AlertReceiver extends BroadcastReceiver {


    @Override
    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", "5 sec hogae hen beta", "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();  // for unique request code

       //   PendingIntent notificationIntent = PendingIntent.getActivity(context, _id, new Intent(context, MainActivity.class), 0);  // changed from 0 to _id

       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));


        notificationManager.notify(1, Ignore());  // changes from 1 to _id
            }
}

// and here is where i'm setting the notification on repeat

   final int _id = (int) System.currentTimeMillis();

        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

    //    alarmManager.set(AlarmManager.RTC_WAKEUP, Allah[i],
      //          PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT));

        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,Allah[i],AlarmManager.INTERVAL_DAY,
                PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT));
shahtaj khalid
  • 476
  • 7
  • 24
  • Have you checked the `adb shell dumpsys alarm` output to see if the alarm is still active? – Nick Friskel Jan 31 '17 at 02:25
  • @nickfriskel I did, please check this question of mine I have posted the output here http://stackoverflow.com/questions/41942221/how-to-read-adb-dumpsys-alarm-output?noredirect=1#comment71064582_41942221 – shahtaj khalid Jan 31 '17 at 07:54

0 Answers0