在单击我的设备中未重定向到我的应用程序活动中的通知时经历错误。
private void processStartNotification() {
Builder builder = new Builder(this);
builder.setContentTitle("DAILY NOTFICATION!")
.setAutoCancel(true).setColor(getResources()
.getColor(R.color.colorPrimary))
.setContentText("CLICK DAILY NOTIFICATION.")
.setSmallIcon(R.mipmap.appicon1)
.setVibrate(new long[] {
1000, 1000, 1000, 1000, 1000
});
builder.setContentIntent(PendingIntent.getActivity(this, NOTIFICATION_ID, new Intent(this, Simplfylast.class), PendingIntent.FLAG_UPDATE_CURRENT));
// The stack builder object will contain an artificial back stack for the started Activity.
// This ensures that navigating backward from the Activity leads out of your application to the Home screen.
builder.setDeleteIntent(NotificationEventReceiver.getDeleteIntent(this));
((NotificationManager) getSystemService("notification")).notify(NOTIFICATION_ID, builder.build());
}
尝试使用此处来自这里的代码
// Create an explicit intent for an Activity in your app
Intent intent = new Intent(this, AlertDetails.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Set the intent that will fire when the user taps the notification
.setContentIntent(pendingIntent)
.setAutoCancel(true);`