I'm trying to create a notification when an alarm fires. No problem so far.
A notification is shown. The problem is on my device (2.1 Update 1) it is displayed as an ongoing notification. While on another device (2.2) it is working fine and is actually shown as a one time only notification. Has anyone experienced this behaviour, and more important has anyone been able to fix it. It seems like 2.1 is not respecting the FLAG_ONLY_ALERT_ONCE
or any flags for that mather. See my code below. Any help would be appreciated.
public class AlarmHandler extends BroadcastReceiver {
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
Debug.log("Alarm notification received");
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = intent.getStringExtra("AlarmType");
CharSequence message = intent.getStringExtra("AlarmType");
Intent newIntent = new Intent(context, Splashscreen.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, intent.getIntExtra("RequestCode", 0),
newIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification notif = new Notification(R.drawable.icon,
null, System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
notif.flags |= Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL;
Debug.log("flags: "+notif.flags);
Debug.log("Defaults: "+notif.flags);
nm.notify(intent.getIntExtra("RequestCode", 0), notif);
}
}