Eu fiz funcionar perfeitamente essa notificação no android 19 e na 21 mas não funciona na 27, 28 e 29.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
private void openNotification(){
Intent intent = new Intent( MainActivity.this, NotificationActivity.class );
intent.putExtra( "msg", msg );
intent.putExtra( "status", status );
intent.putExtra( "time", DataTime );
// int id = 1;
int id = (int) (Math.random() * 1000);
PendingIntent pi = PendingIntent.getActivity( getBaseContext(), id, intent, PendingIntent.FLAG_UPDATE_CURRENT );
Notification notification = new Notification.Builder( getBaseContext() ).setContentTitle( "Evento de Pânico" ).setContentText( msg ).setSmallIcon( R.mipmap.panic ).setContentText( DataTime ).setContentIntent( pi ).build();
NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE );
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify( id, notification );
}
Na API 29 vem uma toast de aviso:
Notification(channel=null pri=0 contentView=null vibrate=null sound=null
defaults=0x0 flags=0x0 color=0x00000000 vis=PRIVATE)
quando funciona na api19 vem o seguinte:
Notification(pri=0 icon=7f0e0005 contentView=br.com.panico/0x109007d vibrate=null sound=null defaults=0x0 flags=0x0 when=1567779581326 ledARGB=0x0 contentIntent=Y deleteIntent=N contentTitle=16 contentText=19 tickerText=N kind=[null])