NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Notification Notification notification = new Notification(); notification.icon = R.drawable.ic_launcher; // 设置通知的图标 notification.defaults |= Notification.DEFAULT_SOUND; // notification.defaults |= Notification.DEFAULT_VIBRATE; notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.when = System.currentTimeMillis(); Intent intent = new Intent(context, MainActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); // notification.setLatestEventInfo(context, "有新消息", message.getContent(), contentIntent); notificationManager.notify(message.getTime().hashCode(), notification);
android 2.3 notifaction 使用
猜你喜欢
转载自zyzzsky.iteye.com/blog/1863420
今日推荐
周排行