我是 android 的初学者。我想在我的应用程序中显示通知。我使用以下代码
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.icon;
CharSequence tickerText = "";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Hello";
CharSequence contentText = "Welcome ";
Intent notificationIntent = new Intent();
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, null, 0);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(HELLO_ID, notification);
但我的问题是每当运行我的应用程序时,意图都会加载图标。然后图标会显示在状态栏中。如何在不使用意图的情况下显示通知?请帮忙