sachi
sachi

Reputation: 479

How to set alarm when phone boot up in android?

I have a alarm function in my application. Alarm will work fine when the phone is ON. Problem is when i switch off or power off the phone(for example i will set alarm for 10.00AM, 10.05, 10.10) and i will switch on by 10.02. I am not getting any alarm notifications and all the alarms are cancelled. I have used Service for getting the alarm and i used permission reciever_boot_complete also. Still i am getting problem. please anybody help me.

Upvotes: 0

Views: 2449

Answers (1)

Huang
Huang

Reputation: 4842

1.As far as I know, Android system doesn't support alarms when the power is off. If you set an alarm and turn the phone off, the phone won't boot up when the alarm time comes. 2.When using AlarmManager to schedule an alarm, take care of the alram type in methods:

public void set (int type, long triggerAtTime, PendingIntent operation) 
public void setRepeating (int type, long triggerAtTime, long interval, PendingIntent operation)

You should use ELAPSED_REALTIME_WAKEUPorRTC_WAKEUP, otherwise, when the screen is off, the alarm won't be triggered. See here:

Upvotes: 2

Related Questions