Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓-提醒通知问题_Java_Android_Android Studio - Fatal编程技术网

Java 安卓-提醒通知问题

Java 安卓-提醒通知问题,java,android,android-studio,Java,Android,Android Studio,我在安卓系统上工作时遇到了一些麻烦。有人知道我的模拟器上缺少了什么吗?我已经读了很多关于提醒通知的话题,但我尝试的一切都没有成功。提前谢谢 private void createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = "channelInality"; String des

我在安卓系统上工作时遇到了一些麻烦。有人知道我的模拟器上缺少了什么吗?我已经读了很多关于提醒通知的话题,但我尝试的一切都没有成功。提前谢谢

private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            CharSequence name = "channelInality";
            String description = "channelDescription";
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel channel = new NotificationChannel(mNotificationChannel, name, importance);
            channel.setDescription(description);
            channel.enableLights(true);
            channel.enableVibration(true);

            NotificationManager notificationManager = InalityAppController.getInstance().getContext().getSystemService(NotificationManager.class);
            notificationManager.createNotificationChannel(channel);
        }
    }

    public void createNotification(String pTitle, String pContent) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(InalityAppController.getInstance().getContext());

        NotificationCompat.Builder notification = new NotificationCompat.Builder(InalityAppController.getInstance().getContext(), mNotificationChannel);
        notification.setSmallIcon(R.drawable.ic_action_people);
        notification.setContentTitle(pTitle);
        notification.setContentText(pContent);
        notification.setAutoCancel(true);
        notification.setPriority(NotificationCompat.PRIORITY_HIGH);
        if (Build.VERSION.SDK_INT >= 21) {
            notification.setVibrate(new long[0]);
        }

        notificationManager.notify(mNotificationID, notification.build());
        mNotificationID++;
    }

你说你读了很多关于Android的通知,但是你读过Android文档吗?我认为如果遵循教程,通知应该会起作用。您如何调用这些方法。分配给的值是什么mNotificationID@Psypher我通过一个按钮调用它们,只是为了测试。问题是通知在«通知中心»中被很好地推送(当向下滑动屏幕时),但在接收时它们不会被正面显示them@LAD基本的通知工作,是的。我遵循了这个文档。但仅限于基本通知,而非正面通知。这就是我发帖的原因。你正在测试的移动操作系统是什么?希望它的安卓5在上面,因为它只能在安卓5上面工作+