因此,我已经尝试了所有我知道的如何在 Android 中制作独特通知的方法,并且我在另一个应用程序中使用了它,但在处理程序中却没有。我基本上有这个:
NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification();
// Create the notification
Notification notification = new Notification(R.drawable.ic_launcher, "No GPS!", System.currentTimeMillis());
Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setAction("actionstring" + System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), msg.arg1, intent,0);
notification.setLatestEventInfo(getApplicationContext(),
Integer.toString(msg.arg1), mString, pendingIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(0, notification);
// Give it an ID
nManager.notify(msg.arg1, n);
但它不会生成唯一的通知,它们会一直被覆盖。我尝试使用 msg.arg1 来控制唯一性,但这似乎没有任何想法?