publicstaticfinalintINCOME_NOTIFY_ID=1;privatevoiddealNotification(PushEntitypushEntity,StringshowBody){NotificationManagernotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);Intentintent;PendingIntentpendingIntent;intent=newIntent(Intent.ACTION_MAIN);// 点击跳转到首页 并且表明要自动登录进去// 这里模拟launcher的intent 否者从桌面上点击会启动新的页面 造成混乱intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED|Intent.FLAG_ACTIVITY_NEW_TASK);intent.setAction(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_LAUNCHER);intent.setComponent(newComponentName(getPackageName(),ChooseUseTypeActivity.class.getName()));pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);UridefaultSoundUri=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);NotificationCompat.BuildernotificationBuilder=newNotificationCompat.Builder(this,channelId).setSmallIcon(R.drawable.ic_rustfisher_logo).setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_rustfisher_logo)).setContentTitle(apsInfo.getAlert()).setContentText("Click me back to app. See an.rustfisher.com").setAutoCancel(true).setTimeoutAfter(30000).setSound(defaultSoundUri).setPriority(Notification.PRIORITY_HIGH).setContentIntent(pendingIntent);// Since android Oreo notification channel is needed.if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){NotificationChannelchannel=newNotificationChannel(channelId,"RustFisher",NotificationManager.IMPORTANCE_HIGH);notificationManager.createNotificationChannel(channel);}notificationBuilder.setTimeoutAfter(30000);notificationManager.notify(INCOME_NOTIFY_ID,notificationBuilder.build());}