Java 错误通知发布致命异常:android.app.RemoteServiceException: 它似乎只出现在三星6.0.1设备上。安卓7还可以。在一些三星设备上内存不足崩溃。我们为温度创建SVG,而不是编程绘制的图标。 Fatal Exception:

Java 错误通知发布致命异常:android.app.RemoteServiceException: 它似乎只出现在三星6.0.1设备上。安卓7还可以。在一些三星设备上内存不足崩溃。我们为温度创建SVG,而不是编程绘制的图标。 Fatal Exception: ,java,android,Java,Android,错误通知发布致命异常:android.app.RemoteServiceException: 它似乎只出现在三星6.0.1设备上。安卓7还可以。在一些三星设备上内存不足崩溃。我们为温度创建SVG,而不是编程绘制的图标。 Fatal Exception: android.app.RemoteServiceException: Bad notification posted Fatal Exception: android.app.RemoteServiceException: Bad noti

错误通知发布致命异常:android.app.RemoteServiceException:
它似乎只出现在三星6.0.1设备上。安卓7还可以。在一些三星设备上内存不足崩溃。我们为温度创建SVG,而不是编程绘制的图标。
 Fatal Exception: android.app.RemoteServiceException: Bad notification posted  Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.noti: Couldn't update icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=com.noti id=0x00000000) visible user=0 )

    Notification.Builder mBuilder = new Notification.Builder(context);

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                mBuilder.setSmallIcon(convertStringToBitmap(StringUtils.appendDegree("12")));
            } else {
                mBuilder.setSmallIcon(R.drawable.notification_icon);
            }

            // Creates an explicit intent for an Activity
            Intent resultIntent = new Intent(context, HomeActivity.class);
            resultIntent.putExtra(AppConstants.IS_ONGOING, true);
            resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);
            mBuilder.setContentIntent(resultPendingIntent);

            Notification notification =mBuilder.build();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                if (getComplexNotificationView(context) != null) {
                    notification.contentView = getComplexNotificationView(context);
                }
                notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
            }
            NotificationManager mNotificationManager =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(0, notification);

    private static Icon convertStringToBitmap(String text) {
            Paint paint = new Paint(ANTI_ALIAS_FLAG);
            paint.setTextSize(100.0f);
            paint.setColor(Color.WHITE);
            paint.setTextAlign(Paint.Align.LEFT);
            float baseline = -paint.ascent(); // ascent() is negative
            int width = (int) (paint.measureText(text) + 0.5f); // round
            int height = (int) (baseline + paint.descent() + 0.7f);
            Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(image);
            canvas.drawText(text, 0, baseline, paint);
            return Icon.createWithBitmap(image);
        }