点击通知并不是仅在AndroidOS Oreo中启动预期活动?
单击设备中未重定向到应用程序活动的通知时出错点击通知并不是仅在AndroidOS Oreo中启动预期活动?,android,android-intent,android-notifications,Android,Android Intent,Android Notifications,单击设备中未重定向到应用程序活动的通知时出错 private void processStartNotification(){ 建筑商=新建筑商(本); builder.setContentTitle(“每日通知!”) .setAutoCancel(true).setColor(getResources() .getColor(R.color.colorPrimary)) .setContentText(“单击每日通知”) .setSmallIcon(R.mipmap.appicon1) .设置
private void processStartNotification(){
建筑商=新建筑商(本);
builder.setContentTitle(“每日通知!”)
.setAutoCancel(true).setColor(getResources()
.getColor(R.color.colorPrimary))
.setContentText(“单击每日通知”)
.setSmallIcon(R.mipmap.appicon1)
.设置振动(新长[]{
1000, 1000, 1000, 1000, 1000
});
setContentIntent(PendingEvent.getActivity(this,NOTIFICATION_ID,new Intent(this,Simplfylast.class),PendingEvent.FLAG_UPDATE_CURRENT));
//stack builder对象将包含已启动活动的人工后台堆栈。
//这确保了从“活动”向后导航会从应用程序返回主屏幕。
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);`