小编Gur*_*ran的帖子

Android通知无法获得声音和振动

我在我的应用程序中使用了FCM通知,我正在接收它们,它正在显示标题和消息

但是,当我收到通知时,我没有任何声音或振动或任何Led灯指示

我的通知生成器代码是

    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

    builder.setSmallIcon(R.drawable.applogo);
    builder.setContentTitle(Title);
    builder.setContentText(Message);
    builder.setAutoCancel(true);
    builder.setSound(Uri.parse("file:///android_asset/notification.mp3"));
    builder.setContentIntent(pendingIntent);
    builder.setDefaults(Notification.DEFAULT_VIBRATE);
    builder.setLights(Color.RED, 1000, 300);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, builder.build());
Run Code Online (Sandbox Code Playgroud)

提前致谢.

notifications android push-notification firebase

5
推荐指数
1
解决办法
1973
查看次数