Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.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设备中获取空白通知_Android_Push Notification_Notifications - Fatal编程技术网

在某些Android设备中获取空白通知

在某些Android设备中获取空白通知,android,push-notification,notifications,Android,Push Notification,Notifications,在某些设备中,我收到一个空白(白色)通知,就像附加的屏幕截图一样。在某些设备中,它工作正常。请帮我解决这个问题。 尝试用这种方法将setBigContentView设置为NotificationCompat.Builder,检查它是否工作:- Intent intent = new Intent(ctx, NotificationDetailActivity.class); intent.putExtra("id", id); PendingIntent pendingInte

在某些设备中,我收到一个空白(白色)通知,就像附加的屏幕截图一样。在某些设备中,它工作正常。请帮我解决这个问题。


尝试用这种方法将
setBigContentView
设置为
NotificationCompat.Builder
,检查它是否工作:-

Intent intent = new Intent(ctx, NotificationDetailActivity.class);
    intent.putExtra("id", id);
    PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//        Notification notification = builder.build();
        RemoteViews expandedView =
                new RemoteViews(ctx.getPackageName(), R.layout.custom_notification);
        if (Build.VERSION.SDK_INT >= 16)
        {
            builder.setTicker(getResources().getString(R.string.app_name));
            // Sets the small icon for the ticker
            builder.setSmallIcon(getNotificationIcon());
            builder.setLargeIcon(result);
            builder.setColor(getResources().getColor(R.color.colorPrimary));
            builder.setContentTitle(title);
            builder.setContentText(messageBody);
            builder.setSound(defaultSoundUri);
            builder.setContentIntent(pendingIntent);
            builder.setAutoCancel(true);
            // Inflate and set the layout for the expanded notification view
            expandedView.setImageViewBitmap(R.id.imgBigImage, result);
//            notification.bigContentView = expandedView;
            builder.setCustomBigContentView(expandedView);
        } else {
            builder.setSmallIcon(getNotificationIcon());
            builder.setLargeIcon(result);
            builder.setColor(getResources().getColor(R.color.colorPrimary));
            builder.setContentTitle(title);
            builder.setContentText(messageBody);
            builder.setAutoCancel(true);
            builder.setSound(defaultSoundUri);
            builder.setContentIntent(pendingIntent);
        }
        nm.notify(Integer.parseInt(id), builder.build());

Lolipop及以上版本,您将获得该问题。不是吗?在这里添加通知代码..请添加您的code@NilamVaddoriya我添加了代码。请复习it@AnkitaGuna该设备的安卓版本中有哪些空白通知?@AnkitaGuna现在的问题可能是
expandedView
。因此,第一条注释
builder.setCustomBigContentView(expandedView)行并尝试检查。@AnkitaGuna OK。然后查找并正确设置
RemoteView
将解决您的问题。@nitipatel当我对该行进行注释时,它对我有效,但为什么?
Intent intent = new Intent(ctx, NotificationDetailActivity.class);
    intent.putExtra("id", id);
    PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//        Notification notification = builder.build();
        RemoteViews expandedView =
                new RemoteViews(ctx.getPackageName(), R.layout.custom_notification);
        if (Build.VERSION.SDK_INT >= 16)
        {
            builder.setTicker(getResources().getString(R.string.app_name));
            // Sets the small icon for the ticker
            builder.setSmallIcon(getNotificationIcon());
            builder.setLargeIcon(result);
            builder.setColor(getResources().getColor(R.color.colorPrimary));
            builder.setContentTitle(title);
            builder.setContentText(messageBody);
            builder.setSound(defaultSoundUri);
            builder.setContentIntent(pendingIntent);
            builder.setAutoCancel(true);
            // Inflate and set the layout for the expanded notification view
            expandedView.setImageViewBitmap(R.id.imgBigImage, result);
//            notification.bigContentView = expandedView;
            builder.setCustomBigContentView(expandedView);
        } else {
            builder.setSmallIcon(getNotificationIcon());
            builder.setLargeIcon(result);
            builder.setColor(getResources().getColor(R.color.colorPrimary));
            builder.setContentTitle(title);
            builder.setContentText(messageBody);
            builder.setAutoCancel(true);
            builder.setSound(defaultSoundUri);
            builder.setContentIntent(pendingIntent);
        }
        nm.notify(Integer.parseInt(id), builder.build());