为了账号安全,请及时绑定邮箱和手机立即绑定

我没有收到奥利奥和上层的通知

我没有收到奥利奥和上层的通知

慕沐林林 2022-06-23 19:26:53
我必须在android oreo 和upper 上进行通知,但它没有显示,我该如何解决我的问题?我尝试从 androiddevelopers.com 执行指令,但没有帮助,任何人都可以帮助我使用此代码吗?对不起我的英语不好。if (newCount > 0) {if (PrefUtils.getBoolean(PrefUtils.NOTIFICATIONS_ENABLED, true)) {                        Cursor cursor = getContentResolver().query(EntryColumns.CONTENT_URI, new String[]{Constants.DB_COUNT}, EntryColumns.WHERE_UNREAD, null, null);                        cursor.moveToFirst();                        newCount = cursor.getInt(0); // The number has possibly changed                        cursor.close();                        if (newCount > 0) {                            String text = getResources().getQuantityString(R.plurals.number_of_new_entries, newCount, newCount);                            Intent notificationIntent = new Intent(FetcherService.this, HomeActivity.class);                            PendingIntent contentIntent = PendingIntent.getActivity(FetcherService.this, 0, notificationIntent,                                    PendingIntent.FLAG_UPDATE_CURRENT);                            Notification.Builder notifBuilder = new Notification.Builder(MainApplication.getContext()) //                                    .setContentIntent(contentIntent) //                                    .setSmallIcon(R.drawable.ic_statusbar_rss) //                                    .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) //                                    .setTicker(text) //                                    .setWhen(System.currentTimeMillis()) //                                    .setAutoCancel(true) //                                    .setContentTitle(getString(R.string.spaRSS_feeds)) //                                    .setContentText(text) //                                    .setLights(0xffffffff, 0, 0);
查看完整描述

1 回答

?
萧十郎

TA贡献1815条经验 获得超13个赞

从 Android 8 开始,所有通知都必须分配给NotificationChannel在这里您可以找到有关它的信息。

希望它会有所帮助


查看完整回答
反对 回复 2022-06-23
  • 1 回答
  • 0 关注
  • 105 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号