RemoteViews и проблема Пикассо с API 24 и выше - PullRequest
0 голосов
/ 16 декабря 2018

Я использую эти строки кода для получения уведомлений с изображением, загруженным с URL-адреса с библиотекой Picasso

                // Default stuff; making and showing notification
                final Context context = getApplicationContext();
                final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                final Notification notification = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.notification_icon) // Needed for the notification to work/show!!
                        .setContentTitle(eventName)
                        .setContentText(eventTime)
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.logo))
                        .setStyle(new NotificationCompat.BigPictureStyle())
                        .build();
                final int notifId = 1337;
                notificationManager.notify(notifId, notification);
                final RemoteViews bigContentView = 
                notification.bigContentView;
                final int bigIconId = getResources().getIdentifier("android:id/big_picture", null, null);
Picasso.with(getApplicationContext()).load(imageUrl).into(bigContentView,bigIconId, notifId, notification);
                }

Код отлично работает в API 21, проверял его несколько раз, но на более высоких API, таких как API 24, онвыдает ошибку говорит, что «RemoteViews не должны быть нулевыми».

вот ошибка точно:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.domain.firebaseapp, PID: 31642
    java.lang.IllegalArgumentException: RemoteViews must not be null.
        at com.squareup.picasso.RequestCreator.into(RequestCreator.java:540)
        at com.domain.firebaseapp.BackgroundService$1.onChildAdded(BackgroundService.java:94)
        at com.google.android.gms.internal.firebase_database.zzbt.zza(Unknown Source)
        at com.google.android.gms.internal.firebase_database.zzgx.zzdr(Unknown Source)
        at com.google.android.gms.internal.firebase_database.zzhd.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:754)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6238)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
...