List of usage examples for android.media AudioAttributes USAGE_NOTIFICATION_COMMUNICATION_INSTANT
int USAGE_NOTIFICATION_COMMUNICATION_INSTANT
To view the source code for android.media AudioAttributes USAGE_NOTIFICATION_COMMUNICATION_INSTANT.
Click Source Link
From source file:org.smssecure.smssecure.notifications.MessageNotifier.java
private static void sendInThreadNotification(Context context, Recipients recipients) { if (!SilencePreferences.isInThreadNotifications(context) || ServiceUtil.getAudioManager(context).getRingerMode() != AudioManager.RINGER_MODE_NORMAL) { return;/* ww w. ja va 2s. co m*/ } Uri uri = recipients != null ? recipients.getRingtone() : null; if (uri == null) { String ringtone = SilencePreferences.getNotificationRingtone(context); if (ringtone == null) { Log.w(TAG, "ringtone preference was null."); return; } uri = Uri.parse(ringtone); if (uri == null) { Log.w(TAG, "couldn't parse ringtone uri " + ringtone); return; } } if (uri.toString().isEmpty()) { Log.d(TAG, "ringtone uri is empty"); return; } Ringtone ringtone = RingtoneManager.getRingtone(context, uri); if (ringtone == null) { Log.w(TAG, "ringtone is null"); return; } if (Build.VERSION.SDK_INT >= 21) { ringtone.setAudioAttributes( new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) .setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build()); } else { ringtone.setStreamType(AudioManager.STREAM_NOTIFICATION); } ringtone.play(); }