0

after reading all the QA i didnt get any proper solution. I have 2 problems
1. Alarm fires twice even if i register my receiver only in manifest.(not by code)
2. when i update interval time of alarm it gets fires randomly

here is my method for set alarm

public void AlarmCall(int min) {

Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent pintent = PendingIntent.getBroadcast(context,0 , intent, 0);
alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
cancelAlarm(alarm,pintent);
    if(Build.VERSION.SDK_INT<18) {
        alarm.set(AlarmManager.RTC_WAKEUP, 1000 * 60 * min, pintent);
      }
    else if(Build.VERSION.SDK_INT>=19 && Build.VERSION.SDK_INT<=22)
    {             alarm.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(), 1000*60*min, pintent);
    }
    else if(Build.VERSION.SDK_INT>=23)
    {         alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP,1000*60*min,pintent);
    }
}

method to cancel alarm :

public void cancelAlarm(AlarmManager alarm,PendingIntent p)
{
alarm.cancel(p);
Log.d("Alarm","Alarm Cancle");
}

in my project Application class i have to start alarm with 10 min time interval and it works fine , according to user input value i need to update time interval.
so i call this method with int min input value and cancel first alarm. but in marshmallow it fires at every 5 seconds, and kitkat lollipop it fires randmoly.
even checked with setExact() method

Bipin Gawand
  • 521
  • 1
  • 6
  • 17
  • Please don't repeat questions. Simply editing your original post with any new information you have, any new code you've tried, or an explanation of why any posted answers aren't working will bump it to the top of the active queue. – Mike M. Mar 11 '17 at 06:45
  • sorry but because of i ddnt get any answer – Bipin Gawand Mar 11 '17 at 06:46

0 Answers0