使用notificationlistner android未检索来自堆栈通知的图像

问题描述

    private String getNotificationImage(Notification notification) {
        try {
            if (!notification.extras.containsKey(Notification.EXTRA_PICTURE)) return "";

            Bitmap imageBitmap = (Bitmap) notification.extras.get(Notification.EXTRA_PICTURE);

            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = this.calculateInSampleSize(options,100,100);
            options.inJustDecodeBounds = false;
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            imageBitmap.compress(Bitmap.CompressFormat.JPEG,30,outputStream);

            String result = Base64.encodetoString(outputStream.toByteArray(),Base64.DEFAULT);

            return TextUtils.isEmpty(result) ? result : "data:image/png;base64," + result;
        } catch (Exception e) {
            Log.d(TAG,e.getMessage());
            return "";
        }
    }

我可以使用notificationlistner从通知获取图像,但不能在whatsapp和telegram等应用程序中堆叠/分组通知的情况下

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)