Здравствуйте, друзья, мое push-уведомление не работает на Android 5.0 Lollipop Я проверил этот код на 6.0 работает нормально, но не работает на устройстве 5.0 huawei здесь код Что я могу сделать сейчас, пожалуйста, помогите, как исправить эту проблему, я застрял на этом шаге я сделал почти весь шаг я новичок
Bitmap largeImage = BitmapFactory.decodeResource(getResources(),R.drawable.musicicon);
//Intent pauseIntent = new Intent("music.playerforandroid.ACTION_PAUSE_MUSIC");
PendingIntent pausePendingIntent = PendingIntent.getBroadcast(this, 1, new Intent("music.playerforandroid.ACTION_PAUSE_MUSIC"), 0);
PendingIntent playPendingIntent = PendingIntent.getBroadcast(this, 1, new Intent("music.playerforandroid.ACTION_PLAY_MUSIC"), 0);
PendingIntent nextPendingIntent = PendingIntent.getBroadcast(this, 1, new Intent("music.playerforandroid.NEXT_PLAY_MUSIC"), 0);
PendingIntent perviousPendingIntent = PendingIntent.getBroadcast(this, 1, new Intent("music.playerforandroid.PERVIOUS_PLAY_MUSIC"), 0);
Notification channel = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID_1)
.setSmallIcon(R.drawable.ic_music)
.setContentTitle(song.getTitle())
.setContentText(song.getArtist())
.setLargeIcon(largeImage)
.addAction(R.drawable.ic_prev, "prev", perviousPendingIntent)
.addAction(R.drawable.ic_play, "play", playPendingIntent)
.addAction(R.drawable.ic_stat_name, "pause", pausePendingIntent)
.addAction(R.drawable.ic_next, "next", nextPendingIntent)
.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle().
setShowActionsInCompactView(1, 2, 3))
.build();
mNotificationManagerCompat.notify(1, channel);
package music.playerforandroid;
import android.app.Application;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
public class App extends Application {
public static final String CHANNEL_ID_1 = "channel1";
public static final String CHANNEL_NAME_1 = "FIRSTCHANNEL";
@Override
public void onCreate() {
super.onCreate();
createNotificationChannel();
}
private void createNotificationChannel() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channle1 = new NotificationChannel(
CHANNEL_ID_1,
CHANNEL_NAME_1,
NotificationManager.IMPORTANCE_HIGH
);
channle1.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
channle1.enableLights(true);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channle1);
}
}
}
и я получаю эту ошибку
E/MediaPlayer: должен быть уже установлен контроллер субтитров. E/MediaPlayer: должен быть уже установлен контроллер субтитров. E/AndroidRuntime: FATAL EXCEPTION: main Process: music.playerforandroid, PID: 22269 android.app.RemoteServiceException: Плохое уведомление, отправленное из музыки пакета. playerforandroid: Не удалось развернуть RemoteViews для: StatusBarNotification (pkg = music.playerforandroid user = UserHandle {0} id = 1 тег = нулевой счет = 0 key = 0 | music.playerforandroid | 1 | null | 10112: Уведомление (pri = 0 contentView = music.playerforandroid/0x109007f vibrate = нулевой звук = нулевые значения по умолчанию = 0x0 flags = 0x0 color = 0x00000000 category = транспортные действия = 4 vis = PRIVATE)) в android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1534) на android.os.Handler.dispatchMessage(Handler.java:102) на android.os.Looper.loop(Looper.java:135) на android.app.ActivityThread.main(ActivityThread.java:5538) на java.lang. refle.Method.invoke (собственный метод) на java.lang.reflect.Method.invoke(Method.java:372) на com.android.internal.os.Zyg oteInit $ MethodAndArgsCaller.run(ZygoteInit.java:960) на com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Я рекомендую вам использовать это. Это отправка уведомления с вашего сервера на сервер платформы и сервер платформы на сервер Google, который отправляет вам "push-уведомление", вы также можете найти способ установить это. Удачи.