我使用以下代码在我的Android应用程序中生成通知。
一切正常,但振动连续仍然会在生成新通知时单击通知栏。 这只是在KitKat ,在剩下的所有工作正常。任何的想法 ?
private static void generateNotification(Context context, String message) {
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, message, when);
String title = "Application Name";
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra("message", message);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults|= Notification.DEFAULT_LIGHTS;
notification.defaults|= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.DEFAULT_LIGHTS;
notificationManager.notify(0, notification);
}
提前致谢