alarm reminder not working - android

I am trying to create reminder using alarm manager. But seems it's not working. I am trying to set multiple reminder using different id but my broadcastreceiver not getting called. I am not seeing any notification or nor any sound.
I have tried 30-40 times.
I am setting date to calender like 25/11/2014
Here is myactivity code which setting alarm notification.
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2014);
calendar.set(Calendar.MONTH, 11);
calendar.set(Calendar.DAY_OF_MONTH, 25);
calendar.set(Calendar.HOUR_OF_DAY, 19);
calendar.set(Calendar.MINUTE, 30);
//calendar.set(Calendar.SECOND, 1);
Intent myIntent = new Intent(CreateReminder.this, MyReceiver.class);
myIntent.putExtra("reminder_id",reminderid);
myIntent
.setAction("com.sandeep.alarm.REMINDER");
PendingIntent pendingIntent = PendingIntent.getBroadcast(
CreateReminder.this, reminderid, myIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
pendingIntent);
MyReceiver.class
public class MyReceiver extends BroadcastReceiver {
private Ringtone r;
#SuppressWarnings("deprecation")
#Override
public void onReceive(Context context, Intent intent) {
int ID=intent.getExtras().getInt("reminder_id");
Log.i("CreateReminder", "reminder_id:-"+ID);
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, "reminder", when);
String title = context.getString(R.string.app_name);
String subTitle = "Please complete task";
Intent notificationIntent = new Intent(context, ReminderActivity.class);
notificationIntent.putExtra("reminder_id", ID);
PendingIntent intent1 = PendingIntent.getActivity(context, 0,notificationIntent, 0);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
notification.setLatestEventInfo(context, title, subTitle, intent1);
//To play the default sound with your notification:
//notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_INSISTENT;
//notification.defaults |= Notification.;
notificationManager.notify(0, notification);
Uri notification1 = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
r = RingtoneManager.getRingtone(context, notification1);
r.play();
new Handler().postDelayed(new Runnable(){
public void run() {
r.stop();
}
}, 10000);
}
}
I am registering my receiver in AndroidManifest.xml with permissions.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.sandip.remindme.CreateReminder"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.sandip.remindme.ReminderActivity"></activity>
<receiver android:name="com.sandip.remindme.MyReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.sandeep.alarm.REMINDER" />
</intent-filter>
</receiver>
</application>
I don't understand why it's not working. Please give me some hints or reference.

You are not sending your broadcast after you set your action in your intent.
Intent myIntent = new Intent(CreateReminder.this, MyReceiver.class);
myIntent.putExtra("reminder_id",reminderid);
myIntent
.setAction("com.sandeep.alarm.REMINDER");
sendbroadcast(myIntent);//YOU FORGOT TO ADD THIS

I have compared your code to mine and have a couple of things for you to try...
Is com.sandeep.alarm a real namespace? The activities within your app have the differing namespace com.sandip.remindme so you could use this ("com.sandip.remindme.REMINDER") for your action name.
Your intent is created with a specific context and class target. Try constructing it with just the action name, then you will know if the action name is the issue:
Intent myIntent = new Intent("com.sandip.remindme.REMINDER")

I'm also working on Alarm remainder and I've implemented successfully in my app. you can download the example code in the following link. I hope it helps you. Please note that alarm takes 30secs to 1 min to call broadcast receiver. i.e., if you set alarm at 3:30:00pm then broad cast receiver will be called at around 3:30:30pm.
https://www.dropbox.com/s/t2m5ph8s8f17v6m/AndroidAlarmManager.zip?dl=0
Thanks
Ramesh

You're never sending the broadcast.
sendbroadcast(myIntent);
Add that directly after you do .setAction, and the code should work just fine.

Related

Notification triggered immediately and not at the time I wanted it to be triggered

I'm relatively new to Android so I'm quite puzzled here...
I want a notification to be triggered at a certain time on a daily basis.
I use a Calendar class to set the time when the notification is triggered every day, and AlarmManager to set the repeating task.
The problem is, the notification is triggered when the app is initially launched and not at the pre-defined time configured in the Calendar object. When I run in debug mode, I see that I go to the setExact method.
I also created a receiver to handle the notification itself and open the MainActivity when the notification is clicked.
MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
.
.
.
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 8);
calendar.set(Calendar.MINUTE, 30);
calendar.set(Calendar.SECOND, 0);
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
if (Build.VERSION.SDK_INT < 19)
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
else
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
NotificationReceiver.java
public class NotificationReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent mainIntent = new Intent(context, MainActivity.class);
mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 100, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle("This is the title")
.setContentText("This is the text")
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.deal_icon);
Notification notification = builder.build();
notification.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
manager.notify(100, notification);
}
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.goldbox.goldboxdeals">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:name="com.sample.sample1.ApplicationHelper"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".NotificationReceiver" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
Calendar.getInstance() returns a calendar at your current local time. You're then setting the time to be what you wish, with today's date. When you schedule an alarm, the date is likely in the past. The system then will trigger the alarm immediately.
I believe you should use setRepeating(). You can set the trigger / interval times. Keep in mind that your app, or even the device itself, isn't necessarily running all the time.

Android notifications after "all app close" button

I am using notifications in my application and everything works well - the notification is showing at desired time to me, even after device reboot.
However, when I click the special button to close all apps, so it closes my app, the notification is not showing at all.
"The special button to close all apps" - I mean the one where you can list all the background apps and then with one click kill them all.
I am testing everything on OnePlus 3T.
Is it possible to run the service again after that "kill all apps" click ?
manifest:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
...
<receiver
android:name="com.saga.thewitcherquotes.QuoteOfTheDayReceiver"
android:enabled="true"
android:exported="false" >
</receiver>
<receiver android:name="com.saga.thewitcherquotes.DeviceBootReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name="com.saga.thewitcherquotes.QuoteOfTheDayIntentService"
android:exported="false"></service>
BootReceiver:
public class DeviceBootReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
// on device boot compelete, reset the alarm
Intent alarmIntent = new Intent(context, QuoteOfTheDayReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Calendar current = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 21);
calendar.set(Calendar.MINUTE, 30);
if(calendar.before(current))
{
calendar.add(Calendar.DATE, 1);
}
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
AlarmManager.INTERVAL_DAY, pendingIntent);
}
}
}
The service with notification builder:
public class QuoteOfTheDayIntentService extends IntentService {
private static final int NOTIFICATION_ID = 3;
public QuoteOfTheDayIntentService() {
super("MyNewIntentService");
}
#Override
protected void onHandleIntent(Intent intent) {
Notification.Builder builder = new Notification.Builder(this);
builder.setContentTitle(getString(R.string.quote_of_the_day));
DatabaseHandler db = DatabaseHandler.getInstance(this);
Random generator = new Random();
int id = generator.nextInt(db.getQuotesSize());
Quote quote = db.getQuote(id, null);
builder.setContentText(quote.getQuote());
builder.setSmallIcon(R.drawable.swords);
builder.setAutoCancel(true);
Intent notifyIntent = new Intent(this, MainActivity.class);
notifyIntent.putExtra("id",id-1);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
Notification notificationCompat = builder.build();
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(this);
managerCompat.notify(NOTIFICATION_ID, notificationCompat);
}
}

How to trigger Notification in background?

I'm trying to trigger a notification every 15 minutes, starting from the time I set. Currently my app notifies only when my application is open or when it is in the recent applications but when i closed my application the notification doesn't work any longer but when i open again my app it will trigger the notification. Based on my research I need a Service. So I have 3 files.
In my MainActivity, i set the alarm
private void scheduleNotification(int week){
Intent notificationIntent = new Intent(this, NotificationPublisher.class);
notificationIntent.putExtra("notifId", getResources().getInteger(R.integer.notification_id));
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, getResources().getInteger(R.integer.notification_id), notificationIntent, 0);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, week);
calendar.set(Calendar.HOUR_OF_DAY, 9);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent);
}
in the MainActivity i call a BroadcastReceiver which is the NotificationPublisher. Here is my NotificationPublisher
public class NotificationPublisher extends BroadcastReceiver {
final String TAG = "NotificationPublisher";
public void onReceive(Context context, Intent intent) {
Intent service = new Intent(context, NotificationAlarmService.class);
service.putExtra("notifId", intent.getIntExtra("notifId", 0));
context.startService(service);
}
then I start a service by using the BroadcastReceiver which is the NotificationAlarmService, here i build a Notification using NotificationCompat.Builder.
public class NotificationAlarmService extends Service {
. . . .
#Override
public int onStartCommand(Intent intent,int flag, int startId)
{
notificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent mIntent = new Intent(this, MainActivity.class);
pendingIntent = PendingIntent.getActivity(this, intent.getIntExtra("notifId", 0), mIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("App");
builder.setContentText("Notify Me");
builder.setAutoCancel(true);
builder.setSmallIcon(getNotificationIcon());
builder.setContentIntent(pendingIntent);
notificationManager.notify(intent.getIntExtra("notifId", 0), builder.build());
return super.onStartCommand(intent, flag, startId);
}
I already tried returning START_STICKY instead of super.onStartCommand I understand that when i used a service it will run in the background even if the user closed the application. I also tried changing this and used getBaseContext() in the service but this it doesn't trigger the notification. I don't know if i'm missing something. Thank you in advance.
EDIT
Here is my Manifest
<receiver android:name=".NotificationPublisher"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:name=".NotificationAlarmService"
android:enabled="true">
</service>
After a week, I finally got it. In my Manifest i put something like this
<receiver android:name=".NotificationPublisher">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<service android:name=".NotificationAlarmService"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="NOTIFICATION_SERVICE" />
</intent-filter>
</service>
i've removed the enabled="true" in the receiver and also add QUICKBOOT_POWERON. Then add an action in the service which is NOTIFICATION_SERVICE and call it in my service like this
NotificationManager mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
Try adding Service in your Manifest file (Same as declaring an Activity) under application tag like this,
<service android:name="com.example.android.NotificationAlarmService">
</service>

Android Scheduled Notification not working

I am building an android app to display recurring scheduled notification at a specified time of the day.
For this I have created broadcastReceiver using following code:
public class ScheduleNotification extends BroadcastReceiver {
public static final int NOTIFICATION_ID = 1;
#Override
public void onReceive(Context context, Intent intent) {
long when = System.currentTimeMillis();
MainActivity mainActivity = new MainActivity();
String _pasuram_number = mainActivity.get_pasuram_number();
String[] _pasuram_str = mainActivity.get_dd_text(_pasuram_number).split(",");
Log.d("VC", "Notification intent paasuram " + _pasuram_number);
intent.putExtra("pasuramnumber", _pasuram_number);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent snoozeIntent = new Intent(context, MainActivity.class);
PendingIntent piSnooze = PendingIntent.getService(context, 0, snoozeIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(R.drawable.ic_stat_name);
builder.setContentIntent(pendingIntent);
builder.setAutoCancel(true);
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_name));
builder.setContentTitle("Title of the notification");
builder.setContentText(_pasuram_str[9]+"-"+_pasuram_str[11]);
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(_pasuram_str[0] + "-" + _pasuram_str[8]));
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
}
In the MainActivity added code to create alarm
private void createScheduledNotification(int days)
{
// Get new calendar object and set the date to now
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
// Add defined amount of days to the date
calendar.set(Calendar.HOUR_OF_DAY, 6);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
//calendar.add(Calendar.HOUR_OF_DAY, days * 24);
// Retrieve alarm manager from the system
AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(getBaseContext().ALARM_SERVICE);
// Every scheduled intent needs a different ID, else it is just executed once
int id = (int) System.currentTimeMillis();
// Prepare the intent which should be launched at the date
Intent intent = new Intent(this, ScheduleNotification.class);
// Prepare the pending intent
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Register the alert in the system. You have the option to define if the device has to wake up on the alert or not
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
//alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
The code compiles fine and application runs, but scheduled notification does not appear as expected.
In the manifest file added receiver as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vaishnavism.eclass.dinamorudivyaprabandam" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- permission required to use Alarm Manager -->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<!-- Register the Alarm Receiver -->
<receiver android:name="com.vaishnavism.eclass.dinamorudivyaprabandam.ScheduleNotification"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.vaishnavism.eclass.dinamorudivyaprabandam.MainActivity" />
</activity>
</application>
</manifest>
Any help to resolve the issue is greatly appreciated.
Thanks
Try to use set your alarm like below :
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 6);
calendar.set(Calendar.MINUTE, 0);
int interval = 1000 * 60 * 60 * 24;
Intent myIntent = new Intent(yourActivity.this, ScheduleNotification .class);
pendingIntent = PendingIntent.getBroadcast(UserDashBoardActivity.this, 0, myIntent,0);
/* Repeating on every 24 hours interval */
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), interval, pendingIntent);
And you need to start an Alarm When the Device Boots.
For more info refere here.
Hope it will help you.

Android - Create Repeating Notification At Set Time

I have looked through a ton of documentation and stackoverflow questions on how to set a repeating notification set to a certain time but can not get any of them to work. Here is what I have right now.
The method I set up the AlarmManager in:
//set alarm method
private void setAlarm() {
if(enableCheckBox.isChecked()) {
//save time / title / message
mTinyDB.putInt(Constants.SAVED_HOUR, timePicker.getCurrentHour());
mTinyDB.putInt(Constants.SAVED_MINUTE, timePicker.getCurrentMinute());
mTinyDB.putString(Constants.SAVED_TITLE, titleEditText.getText().toString().trim());
mTinyDB.putString(Constants.SAVED_MESSAGE, messageEditText.getText().toString().trim());
mTinyDB.putBoolean(Constants.SAVED_NOTIFICATION_ENABLED, enableCheckBox.isChecked());
//create repeating notification
Intent intent = new Intent(NotificationActivity.this, Notify.class);
AlarmManager manager = (AlarmManager) getSystemService(Activity.ALARM_SERVICE);
PendingIntent pendingIntent = PendingIntent.getService(this,
0, intent, 0);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, mTinyDB.getInt(Constants.SAVED_HOUR, 0));
cal.set(Calendar.MINUTE, mTinyDB.getInt(Constants.SAVED_MINUTE, 0));
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
manager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 24 * 60 * 60 * 1000, pendingIntent);
}
}
The Notify class which extends BoradcastReceiver:
public class Notify extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
TinyDB mTinyDB = new TinyDB(context);
Notification builder = new Notification.Builder(context)
.setContentTitle(mTinyDB.getString(Constants.SAVED_TITLE))
.setContentText(mTinyDB.getString(Constants.SAVED_MESSAGE))
.setSmallIcon(R.drawable.ic_action_check)
.setContentIntent(pIntent)
.build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, builder);
}
}
Am I doing this completely wrong? I can't get anything to come up (at least at the set time). Help or guidance is appreciated :)
You're using PendingIntent.getService, but your intent is not for a service. For a BroadcastReceiver, you should be using PendingIntent.getBroadcast.
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
The problem you're running into is that you can't set an exact, repeatable alarm in Android. If you want your repeating alarm to occur at an exact time, you must set a one time exact alarm and recreate it after the alarm goes off in your code.
Citation: Documentation for setRepeating
In order for the system to be able to launch a component, it should be registered in your manifest:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".Notify" />
</application>
</manifest>

Categories

Resources