Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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
Android MIUI提示通知无效_Android_Notifications_Android Notifications_Heads Up Notifications_Miui - Fatal编程技术网

Android MIUI提示通知无效

Android MIUI提示通知无效,android,notifications,android-notifications,heads-up-notifications,miui,Android,Notifications,Android Notifications,Heads Up Notifications,Miui,我正在努力让我的通知显示抬头或偷看,因为它也被称为 它与股票Android和沿袭操作系统API 21-26配合良好 要让它在MIUI8中工作,需要做什么 应用程序具有所有允许的通知权限 这是我的通知代码示例: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { NotificationCompat.Builder notification = new NotificationCompat.Builder(context, "se

我正在努力让我的通知显示抬头或偷看,因为它也被称为

它与股票Android和沿袭操作系统API 21-26配合良好

要让它在MIUI8中工作,需要做什么

应用程序具有所有允许的通知权限

这是我的通知代码示例:

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
    NotificationCompat.Builder notification = new NotificationCompat.Builder(context, "service_notifications")
        .setContentTitle(name)
        .setContentText("\uD83D\uDD14" + res.getText(R.string.imminent_arrival_text) + String.valueOf(Long.parseLong(eta) / 60) + res.getText(R.string.minutes_at_text) + simpleETA)
        .setSmallIcon(R.drawable.ic_stat_name)
        .setContentIntent(null)
        .addAction(R.drawable.ic_dialog_close_light, res.getText(R.string.stop_following_label), closePendingIntent)                                
        .setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.quite_impressed))
        .setVibrate(new long[]{1000, 1000})                                    
        .setPriority(NotificationCompat.PRIORITY_MAX)                                    
        .setCategory(NotificationCompat.CATEGORY_MESSAGE);

    notificationManager.notify(
        Constants.NOTIFICATION_ID.FOREGROUND_SERVICE,
        notification.build());
}
if(Build.VERSION.SDK\u INT
您可以通过两种方式完成此操作

转到:

  • 背景

  • 已安装的应用程序(迁移到您的应用程序)

  • 选择您的应用程序并转到通知(打开优先级并同时打开浮动通知)

  • 或者,创建远程视图(在res/layout中创建自己的布局)并设置
    customHeadsUpNotification

     RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.notif_custom_view);
    
     notification_builder.createHeadsUpContentView(remoteViews);
    

    完成这些更改后,不要忘记更改通知id。

    是否尝试添加振动模式?您好,是的,我有。我在上面添加了一个代码示例。这段代码在android和天堂操作系统上产生了一个正面效果,但在MIUI上没有。。。是的,所有通知权限都已授予该应用。请尝试添加setDefaults(notification.DEFAULT\u all)我已添加MIUi的解决方案,请检查谢谢!这是我第一次在MIUI上触发正面攻击。我将看看现在重建所有通知以使用RemoveView是否有意义。
    CreateHeadUpContentView(RemoteView)
    不将RemoteView作为参数。而且它在MIUI10上对我不起作用。你能帮忙吗,苏尔桑塔努