更新时间:2022-12-19 17:44:01
发送通知时,请使用以下命令:
When sending notification use following :
NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(mContext)
.....;
Intent activityIntent = new Intent(mContext, ShowNotificationActivity.class);
activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, activityIntent, PendingIntent.FLAG_ONE_SHOT);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());