MobMy BrodcastReceiver's OnReceive, it works great only when the app is running in the background, I get the notification no problem, but as soon as the user closes the app and waits for the date he specified to be reminded it crashes, is it because the app isn't running? So I'm guessing it's because my app isn't running so the intents can't be retrieved? That's the reason why it crashes?
How I set my alarms, pretty basic stuff;
public void setAlarm(View view) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, yearDate);
cal.set(Calendar.MONTH, monthDate);
cal.set(Calendar.DAY_OF_MONTH, dayDate);
long alertTime = cal.getTimeInMillis();
Intent alertIntent = new Intent(this, AlertReceiver.class);
// store id
alertIntent.putExtra("id", mainId);
alertIntent.putExtra("name", name);
alertIntent.putExtra("releaseDate", releaseDate);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, mainId, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC_WAKEUP, alertTime, pendingIntent);
}
My BrodcastReceiver's OnReceive
public void onReceive(Context context, Intent intent) {
int id = intent.getIntExtra("id", -1);
String name = intent.getStringExtra("name");
String releaseDate = intent.getStringExtra("releaseDate");
createNotification(context, "Movie Reminder", name + ": " + releaseDate, "Movie Reminder", id);
}
Maybe I could check if my app isn't running in the onReceive() and if not it opens the app?