List of usage examples for android.media AudioAttributes CONTENT_TYPE_UNKNOWN
int CONTENT_TYPE_UNKNOWN
To view the source code for android.media AudioAttributes CONTENT_TYPE_UNKNOWN.
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;// w w w . j ava 2 s . 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(); }