从服务发送通知

时间:2018-07-08 15:16:50

标签: java android multithreading service

我正在尝试提供服务,这将启动Thread,该方法具有发送通知的方法。但是它不发送!

该方法的代码:

private void sendNotification(String lessonName) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentTitle(lessonName)
            .setContentText("Test!")
            .setPriority(NotificationCompat.PRIORITY_DEFAULT);

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
    notificationManager.notify(id, builder.build());
}

谢谢

0 个答案:

没有答案