Alarmmanager not triggering the alarm - android

I am trying to create a daily alarm to send notifications but somehow notifications are not coming.
I have read a lot about it but none of the solution helps.
CreateAlarm function:
public static void createAlarm (Context ctx, String filename, boolean must_create_alarm)
{
// CreateAlarm is called from main activity onCreate method.
// Hence, using SharedPreference to set alarm only once.
// When need to explicitly set the alarm. Client pass
// must_create_alarm boolean to true
SharedPreferences pref = ctx.getSharedPreferences(filename, Context.MODE_PRIVATE);
boolean create_alarm = pref.getBoolean("MY_ALARM", true);
create_alarm |= must_create_alarm;
if (create_alarm == false) {
Log.w ("ALARM INFO","ALARM ALREADY CREATED");
return;
}
Log.w ("ALARM INFO","CREATED FRESH ALARAM");
pref.edit()
.putBoolean("MY_ALARM", false).commit();
// Set the alarm to start at exactly 11:00 a.m.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 21);
AlarmManager alarmMgr = (AlarmManager) ctx.getSystemService(ctx.ALARM_SERVICE);
Intent _alarmIntent = new Intent(ctx, AppBroadCastReceiver.class);
_alarmIntent.setAction("android.intent.action.ALARM_KICK_OFF");
PendingIntent pendingIntent = PendingIntent.getBroadcast(ctx, 1, _alarmIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
Log.w("myApp", "SETTING ALARM");
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, pendingIntent); // Setting notification every DAY
}
AppBroadCastReceiver class:
public class AppBroadCastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
Log.w("myApp", "AppBroadCastReceiver DEVICE REBOTTED");
GeneralUtility.createAlarm(context, "designersarres.designersarees", true);
}
else if (intent.getAction().equals("android.intent.action.ALARM_KICK_OFF")) {
// Alarm is fired. Send notification
Log.w("myApp", "AppBroadCastReceiver ALARM");
GetNotificationMsg msg = new GetNotificationMsg(context);
msg.sendNotification();
}
}
}
AndroidManifest.xml:
<!-- Register the Broadcast Receiver -->
<receiver android:name="designersarres.designersarees.AppBroadCastReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ALARM_KICK_OFF"/>
</intent-filter>
</receiver>
I am stuck on this for last couple of days.
Please let me know what I am missing here or doing something wrong here.
Please let me know if I need to post more code here.

Related

setAlarmClock is not exact

This is my first question on stackoverflow. I have read many similar topics but have been unable to find the problem and I am getting a bit desperate.
I develop an app with an alarm clock. This alarm clock only rings under certain circumstances. If they don't apply, I send a notification to the user and set the next alarm 10 minutes later using setAlarmClock(). If the conditions don't apply until a user specified time, the alarm never goes off.
Now when I leave the phone unobserved for a while and check the notifications, I see that they didn't come in every 10 minutes, but very irregularly. Sometimes it came after 10 minutes, other times 11, 15, 30, or whatever.
The problem only occurs when the phone is not plugged in, and so I figured it has something to do with Android's doze mode. setAlarmClock() should help with this problem but it doesn't. I also tried setExactAndAllowWhileIdle(), but that didn't work either. So if anyone has any idea what the issue might be, I would be really greatful to hear about it.
This is my code:
First, the two methods inside my AlarmController
//this is called the first time an alarm is set
public void registerAlarm(int id, AlarmClock alarm) {
if (alarmManager == null)
alarmManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
Calendar alarmTime = alarm.getAlarmCalendar();
//create alarm intent
Intent intent = new Intent("START_ALARM");
intent.putExtra("alarm_id",id);
PendingIntent alarmIntent = PendingIntent.getBroadcast(ctx, id, intent, 0);
AlarmManager.AlarmClockInfo info = new AlarmManager.AlarmClockInfo(alarmTime.getTimeInMillis(),alarmIntent);
alarmManager.setAlarmClock(info, alarmIntent);
//alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP,alarmTime.getTimeInMillis(),alarmIntent);
}
// This is called if the conditions didn't apply
public void registerSnoozeAlarm(int id, int minutes) {
if (alarmManager == null)
alarmManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
long alarmTime = System.currentTimeMillis() + 1000*60*minutes;
//create alarm intent
Intent intent = new Intent("START_ALARM");
intent.putExtra("alarm_id",id);
PendingIntent alarmIntent = PendingIntent.getBroadcast(ctx, id, intent, 0);
AlarmManager.AlarmClockInfo info = new AlarmManager.AlarmClockInfo(alarmTime, alarmIntent);
alarmManager.setAlarmClock(info, alarmIntent);
//alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime,alarmIntent);
}
The Receiver in the manifest:
<receiver android:name="packagename.AlarmReceiver"
android:exported="false">
<intent-filter>
<action android:name="START_ALARM" >
</action>
</intent-filter>
</receiver>
This is my AlarmReceiver:
public class AlarmReceiver extends WakefulBroadcastReceiver implements Observer{
private Context context;
private AlarmClock alarm;
private Intent intent;
#Override
public void onReceive(Context context, Intent intent) {
this.context = context;
this.intent = intent;
//request data from server
Bundle extras = intent.getExtras();
int alarmID = extras.getInt("alarm_id");
alarm = DataHandler.getInstance(context).getAlarm(alarmID);
DataHandler.getInstance(context).requestDataForAlarm(alarm,this);
}
#Override
public void update(Observable observable, Object data) {
Measurement measurement = (Measurement) data;
if (*someConditionapplies*){
//play ringtone
AlarmSoundController sc = AlarmSoundController.getInstance(context);
sc.playSound(alarm.getAlarmSoundPath());
//send a notification message
ComponentName comp = new ComponentName(context.getPackageName(), AlarmNotificationService.class.getName());
intent.putExtra("alarm_id",alarm.getId());
intent.putExtra("description", alarm.getDescription());
intent.putExtra("data", measurement.getData());
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
else {
//if user specified end time is reached, send final notification, else try again in 10 minutes
Calendar alarmEndTime = alarm.getAlarmEndCalendar();
Calendar now = Calendar.getInstance();
if (now.before(alarmEndTime)) {
//schedule new alarm in 10 minutes
DataHandler.getInstance(context).registerSnoozeAlarm(alarm.getId(),10);
sendNoAlarmNotification(measurement, false);
setResultCode(Activity.RESULT_OK);
}
else{
//send the last notification message
sendNoAlarmNotification(measurement, true);
setResultCode(Activity.RESULT_OK);
}
}
DataHandler.getInstance(context).removeObserver(this);
}
private void sendNoAlarmNotification(Measurement measurement, boolean lastNotification) {
ComponentName comp = new ComponentName(context.getPackageName(), NoAlarmNotificationService.class.getName());
intent.putExtra("alarm_id", alarm.getId());
intent.putExtra("description", alarm.getDescription());
intent.putExtra("wind", measurement.windAvg);
intent.putExtra("last_notification", lastNotification);
intent.setComponent(comp);
startWakefulService(context, intent);
}
}
Thanks a lot in advance!

Alarm Manager set Daily Alarm at a specific time?

I've been working on this application that is supposed to run at a given time daily, except on weekends. I've used an AlarmBroadCastReceiver to fire a certain block of code at a given time. I have this code in my AlarmBroadCastReceiver class:
public void SetAlarm(Context context) {
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
intent.putExtra(ONE_TIME, Boolean.FALSE);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 2);
calendar.set(Calendar.MINUTE, 30);
calendar.set(Calendar.SECOND, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 0, pi);
}
Basically I try and set a repeating alarm on that time.
Then at a press of a button, I have this in my MainActivity where I'm calling it from:
public void onStartAlarmClicked(View view){
Context context = this.getApplicationContext();
if(alarm != null){
Log.e(TAG, "starting alarm");
alarm.SetAlarm(context);
}else{
Log.e(TAG, "Alarm is null");
}
}
where alarm is an object of the AlarmBroadCastReceiver class.
The problem I have with it is that the code only fires once. Once it hits 2:30, it fires. However, when I set the time back to 2:29 and wait for 2:30, or set the date 1 day forward and then set the time to 2:20 and wait for 2:30, the code no longer fires.
I have a feeling I'm overlooking something rather simple with regards to setting the alarm time but I can't see it right now.
Found a better answer from this answer. Tweaked it a bit.
public void Set12nnAlarm(Context context) {
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
intent.putExtra(ONE_TIME, Boolean.FALSE);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
// every day at 9 am
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
// if it's after or equal 9 am schedule for next day
if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 9) {
Log.e(TAG, "Alarm will schedule for next day!");
calendar.add(Calendar.DAY_OF_YEAR, 1); // add, not set!
}
else{
Log.e(TAG, "Alarm will schedule for today!");
}
calendar.set(Calendar.HOUR_OF_DAY, 9);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, pi);
}
You have to setup a BroadcastReceiver to listen to time and date changes, and then reset the alarm.
As you want the receiver to be triggered at all times, it is better to set in the Manifest.
Create class in own file
public class DateTimeChangeReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(Intent.ACTION_TIME_CHANGED) ||
action.equals(Intent.ACTION_TIMEZONE_CHANGED) ||
action.equals(Intent.ACTION_DATE_CHANGED))
{
resetAlarm();
}
}
}
And in the Manifest
<receiver android:name=".DateTimeChangeReceiver ">
<intent_filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.TIME_SET" />
<action android:name="android.intent.action.DATE_CHANGED" />
</intent_filter>
</receiver>

AlarmManager fires late or doesn't fire at all

Hi everybody I'm trying to learn how to use AlarmManager and BroadcastReceiver in Android.
I'm having some problems with the AlarmManager:
I'm setting two alarms at 1 minute distance, but only one fires and it is some minutes late (not predictable i guess).
Here's my main activity (i'm setting Alarms by tapping a button)
public class MainActivity extends AppCompatActivity {
AlarmManager alarmManager;
Intent intent;
PendingIntent pendingIntent;
AtomicInteger atomicInteger;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
intent = new Intent(Constants.EXTENDED_DATA_STATUS);
atomicInteger = new AtomicInteger();
setContentView(R.layout.activity_main);
Button startButton = (Button) findViewById(R.id.start_button);
startButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int id = atomicInteger.incrementAndGet();
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),id,intent,0);
Calendar firstLullo = Calendar.getInstance();
Calendar secondLullo = Calendar.getInstance();
firstLullo.set(Calendar.HOUR_OF_DAY,10);
firstLullo.set(Calendar.MINUTE,55);
secondLullo.set(Calendar.HOUR_OF_DAY,10);
secondLullo.set(Calendar.MINUTE,56);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP,firstLullo.getTimeInMillis(),pendingIntent);
alarmManager.setExact(AlarmManager.RTC_WAKEUP,secondLullo.getTimeInMillis(),pendingIntent);
}
Log.d("ALARM","settato con id " + String.valueOf(id));
}
});
}
}
My Receiver simply shows a Toast and makes the phone vibrate.
Constants.EXTENDED_DATA_STATUS is a string from a Constants class and it's added to the intent-filter of my Reveiver in the Android Manifest.
What am i missing? I googled a lot and only found that i have to use setExact() but no luck..
Thanks in advance
The reason why only one fires is because your canceling your first one always
From the docs: If there is already an alarm scheduled for the same IntentSender, that previous alarm will first be canceled.
To fix this, use different PendingIntents for both alarms.
- To let your receiver fire multiple times, reschedule it in your onReceive()
Example:
Only if u want two receivers apart from eachother!
//Declare AlarmManager
AlarmManager am = (AlarmManager) LayoutActivity.this.getSystemService(ALARM_SERVICE);
//create new calendar instance for your first alarm
Calendar startTime= Calendar.getInstance();
//set the time of your first alarm
firstLullo.set(Calendar.HOUR_OF_DAY,10);
firstLullo.set(Calendar.MINUTE, 55);
firstLullo.set(Calendar.SECOND, 0);
//create a pending intent
PendingIntent firstPI = PendingIntent.getBroadcast(yourActivity.this, 0, new Intent("yourFirstAlarmReceiver"), PendingIntent.FLAG_UPDATE_CURRENT);
//schedule time for pending intent, and set the interval to day so that this event will repeat at the selected time every day
am.setRepeating(AlarmManager.RTC_WAKEUP, firstAlarm.getTimeInMillis(), firstPI);
//----------------------------------------------------
//create new calendar instance for your second alarm
Calendar endCalender = Calendar.getInstance();
//Set the time alarm of your second alarm
secondLullo.set(Calendar.HOUR_OF_DAY,10);
secondLullo.set(Calendar.MINUTE,56);
secondLullo.set(Calendar.SECOND, 0);
//create a pending intent to be
PendingIntent secondPI= PendingIntent.getBroadcast(yourActivity.this, 0, new Intent("yourSecondAlarmReceiver"), PendingIntent.FLAG_UPDATE_CURRENT);
//schedule time for pending intent, and set the interval to day so that this event will repeat at the selected time every day
am.setRepeating(AlarmManager.RTC_WAKEUP, secondLullo.getTimeInMillis(), secondPI);
Register alarms in Manifest.XML:
<receiver android:name="firstAlarm" >
<intent-filter>
<action android:name="yourFirstAlarmReceiver" >
</action>
</intent-filter>
</receiver>
<receiver android:name="secondAlarm" >
<intent-filter>
<action android:name="yourSecondAlarmReceiver" >
</action>
</intent-filter>
</receiver>
Now u can call your alarms with:
First Alarm:
public class yourFirstAlarmReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
//Do something when first alarm goes off
}
}
Second Alarm:
public class yourSecondAlarmReceiverextends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
//Do something when second alarm goes off
}
}
Should help u out.
Yes, of course the above code will trigger only one Alarm, because you are setting same id for both alarms.
Alarm are identified and differentiated by their id in pendingintent.
Use different id for different alarms
Update Code:
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1234 ,intent,0);
alarmManager.setExact(AlarmManager.RTC_WAKEUP,firstLullo.getTimeInMillis(),pendingIntent);
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 5678, intent,0);
alarmManager.setExact(AlarmManager.RTC_WAKEUP,secondLullo.getTimeInMillis(),pendingIntent);

Alarmmanager going off on reboot...but its set for 7 days ahead?

I'm failing to see why this alarm is going off on a reboot...I am setting it 7 days ahead here -
Intent intent = new Intent(MainActivity.this, Reminder.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
MainActivity.this, 1, intent, 1);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
try {
am.cancel(pendingIntent);
} catch (Exception e) {
System.out.println("Derp");
}
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 7);
long time = calendar.getTimeInMillis();
am.set(AlarmManager.RTC_WAKEUP, time,
pendingIntent);
Here is my manifest that I have set for alarm to stick around on a reboot - Reminder is the class receiving the alarm-
<receiver android:name="com.practicum.notifications.Reminder" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
By default, all alarms are canceled when a device shuts down. To prevent this from happening, you can design your application to automatically restart a repeating alarm if the user reboots the device. This ensures that the AlarmManager will continue doing its task without the user needing to manually restart the alarm.
You have to manually reset the alarm once again in Bootup Receiver
public class SampleBootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
// Set the alarm here.
}
}
All alarms are shut off when you power off the Android device.
You need to call setRepeating method
public class AlarmReceiver extends BroadcastReceiver {
private static final int PERIOD=5000;
#Override
public void onReceive(Context ctxt, Intent i) {
scheduleAlarms(ctxt);
}
static void scheduleAlarms(Context ctxt) {
AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(ctxt, YourService.class);
PendingIntent pi = PendingIntent.getService(ctxt, 0, i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + PERIOD, PERIOD, pi);
}
}
Check this answer from CommonsWare.
For future reference, I misunderstood how receving the boot complete action worked. I had the intent filter in both of my receiver classes so they were both running, when instead I needed an intent filter on a new broadcastreceiver class to RESET my alarmmanagers.

AlarmManager inside BroadcastReceiver when BOOT_COMPLETED

I have a Service "GroupsTaskAlarmChecker" that is called every 20 seconds by AlarmManager in onCreate of Groups.class activity this way:
int seconds = 20;
Intent myIntent = new Intent(Groups.this, GroupsTaskAlarmChecker.class);
pendingIntent = PendingIntent.getService(Groups.this, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), seconds * 1000, pendingIntent);
This works perfectly. But I need to do that when device boot.
Then I know I have to make AndroidManifest like this:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver android:name=".ReceiverBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
<category android:name="android.intent.category.HOME">
</category></action></intent-filter>
</receiver>
and then mi broadcastReceiver like this:
public class ReceiverBoot extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
int seconds = 20;
Intent myIntent = new Intent(context, GroupsTaskAlarmChecker.class);
pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), seconds * 1000, pendingIntent);
}
}
but inside this onReceive I dont know how can I do the same that I did before (with intent and alarmManager to start the service each 20 seconds).
Error in this line:
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
Is possible that I can't make an AlarmManager inside BroadcastReceiver?
I thank you all, I am an Android begginer and I need your help. Sorry for my english ;)
To summarize the answers and comments above: the onReceive handler receives a context which can be used to access getSystemService and ALARM_SERVICE. Sample code:
public class MyReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Start periodic service.
Calendar cal = Calendar.getInstance();
Intent srvIntent = new Intent(context, MyService.class);
PendingIntent pIntent = PendingIntent.getService(context, 0, srvIntent, 0);
// Use context argument to access service
AlarmManager alarm =
(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
// Repeat every 5 seconds
alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
5000, pIntent);
}
}
}
Create a new class with this code and of course change MyReceiver and MyService to the names in your implementation.
ALARM_SERVICE is neither defined in the class ReceiverBoot nor in BroadcastReceiver.
You should reference Context.ALARM_SERVICE as the argument for getSystemService(String).
Here is a little contribution, which I believe that can add a more complete vision about achieving the goal of this question.
First: configure a "receiver" inside of the AndroidManifest from your app.
<receiver
android:name=".AlarmBroadcastReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
Second: with a Class that EXTENDS the Abstract Class BroadcastReceiver, you should determine if the Intent Action was "BOOT_COMPLETED". If the condition is satisfied, you can call a method from your class which has all the construction to your Alarm.
See the following snippet bellow.
public class AlarmBroadcastReceiver extends BroadcastReceiver {
String TAG = "ALARMS";
String CLASS = this.getClass().getSimpleName() + ": ";
Context alarmContext;
#Override
public void onReceive(final Context context, Intent intent) {
Log.d(TAG, CLASS + "[START] onReceive()... ");
alarmContext = context;
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Log.d(TAG, CLASS + "BOOT_COMPLETED action has been received.");
setAlarmOnBoot();
}
Log.d(TAG, CLASS + "[END] onReceive()... ");
}
public void setAlarmOnBoot() {
Log.d(TAG, CLASS + "[START] - setAlarmOnBoot()");
final long beginAt = SystemClock.elapsedRealtime() + 60 * 1000;
final long interval = 300000; // 5 minutes
try {
AlarmManager alarm = (AlarmManager) alarmContext.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(alarmContext, AlarmBroadcastReceiver.class);
PendingIntent pIntent = PendingIntent.getService(alarmContext, 0, intent, 0);
alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, beginAt, interval, pIntent);
Log.d(TAG, CLASS + "the Alarm has been configured successfully (5 minutes) of interval.");
} catch (Exception e) {
Log.d(TAG, CLASS + "an exception has ocurred while setting the Alarm...");
e.printStackTrace();
}
Log.d(TAG, CLASS + "[END] - setAlarmOnBoot()");
}
}
in your onReceive:
if ("android.intent.action.BOOT_COMPLETED".equals (intent.getAction())){
//start it again here
}

Categories

Resources