Android 8.0以降の通知では、channelIdを指定する必要があります

@TargetApi(Build.VERSION_CODES.O)
private void createNotificationChannel(String channelId、String channelName、intimportance){ 
    NotificationChannel channel = new NotificationChannel(channelId、channelName、importance); 
    channel.setShowBadge(true); 
    NotificationManager NotificationManager =(NotificationManager)getActivity()。getSystemService(NOTIFICATION_SERVICE); 
    NotificationManager.createNotificationChannel(channel); 
} 

public void sendChatMsg(String title、String content){ 
    NotificationManager manager =(NotificationManager)getActivity()。getSystemService(NOTIFICATION_SERVICE); 
    通知通知=新しいNotificationCompat.Builder(getActivity()、channelId)
            .setContentTitle(title)
            .setContentText(content)
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.app_logo)
            .setLargeIcon(BitmapFactory.decodeResource(getResources()、R.drawable.app_logo)) . 
            setAutoCancel(true)
            .build(); 
    manager.notify(notifyId ++、notification); 
}

おすすめ

転載: blog.csdn.net/qq_27248989/article/details/123252008