0
我正嘗試在片段內使用AppCompat創建通知。 我創造什麼都看不到。安卓 - 沒有出現通知
代碼:
private void createNotification()
{
Context context = getActivity().getApplicationContext();
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ymk_ya_logo)
.setAutoCancel(false)
.setContentTitle("notify")
.setContentText("test");
Notification notification = builder.build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(777, notification);
}