警报管理器中的自定义声音无法播放

时间:2018-06-05 18:37:19

标签: java android push-notification android-broadcastreceiver

我在我的reciever课程中使用此代码在一天的特定时间重复通知,通知工作完美,但声音无法播放

NotificationManager Adhan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent1 = new Intent(context , Splash_Screen.class);


intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context,3,intent1,PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap notification_logo = BitmapFactory.decodeResource(context.getResources(),R.mipmap.muslim);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setContentIntent(pendingIntent)
        .setContentTitle(prayerNames.get(3)+" time at "+myHelper.get_City_Name())
        .setSmallIcon(R.mipmap.muslim)
        .setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.adhan_fajr))
        .setLargeIcon(notification_logo)
        .setAutoCancel(true);

    builder.setDefaults(Notification.DEFAULT_SOUND|Notification.DEFAULT_VIBRATE);
    builder.setVibrate(new long[]{500,1000,500,1000,500});

    Adhan.notify(3,builder.build());

我也尝试过:

//Activity: AlarmIntent.putExtra("Ringtone",getResources().getResourceName(R.raw.shankh_final_mid));
//In my reciever notification.sound = (Uri)(Uri.parse(intent.getStringExtra("Ringtone")));

但与声音一直无关。

0 个答案:

没有答案