I'm building app that reminds user of unread messages. My problem is that after user swipes it out from a list with last used apps, both my broadcast receiver and alarm manager don't work. Is there any solution for that issue?
I have read that adding ' android:process=":remote" 'in receiver's manifest may help, but it doesn't. The app is 'unfortunately closed' after receiving message when this line is in the manifest.
I wonder how do apps like Messenger or Mail work? They have to notify user when the message is received and they are being swiped out by users, same as the other apps.
Here is how I set my alarm:
Intent i = new Intent(MainActivity.mContext,AlarmReceiver.class);
i.putExtra("number",numerNadawcy);
i.putExtra("hour",h);
i.putExtra("minute",m);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent alarmIntent = PendingIntent.getBroadcast(MainActivity.mContext, 123, i, 0);
AlarmManager alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
if(Build.VERSION.SDK_INT>=19)
{
alarmMgr.setExact(AlarmManager.RTC_WAKEUP,System.currentTimeMillis()+h*60*60*1000+m*60*1000,alarmIntent);
}
else
{
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),h*60*60*1000+m*60*1000, alarmIntent);
}