List of usage examples for android.media RingtoneManager getRingtone
public static Ringtone getRingtone(final Context context, Uri ringtoneUri)
From source file:com.mattprecious.notisync.profile.SecondaryCustomProfileActivity.java
private void updateRingtoneSelector() { Uri ringtoneUri = getRingtoneUri(profile.getRingtone()); String ringtoneName = null;//from w ww. j a v a 2 s . c om if (ringtoneUri == null) { ringtoneName = getString(R.string.ringtone_silent); } else { ringtoneName = RingtoneManager.getRingtone(this, getRingtoneUri(profile.getRingtone())).getTitle(this); } ringtoneSelector.setText(ringtoneName); }
From source file:com.philliphsu.clock2.alarms.ui.ExpandedAlarmViewHolder.java
private void bindRingtone() { int iconTint = Utils.getTextColorFromThemeAttr(getContext(), R.attr.themedIconTint); Drawable ringtoneIcon = mRingtone.getCompoundDrawablesRelative()[0/*start*/]; ringtoneIcon = DrawableCompat.wrap(ringtoneIcon.mutate()); DrawableCompat.setTint(ringtoneIcon, iconTint); mRingtone.setCompoundDrawablesRelativeWithIntrinsicBounds(ringtoneIcon, null, null, null); String title = RingtoneManager.getRingtone(getContext(), getSelectedRingtoneUri()).getTitle(getContext()); mRingtone.setText(title);//from w w w .ja v a 2 s .c om }
From source file:com.shivshankar.MyFirebaseMessagingService.java
private void sendNotification(String strTitle, String strMsg) { Log.d("TAGRK", "Preparing to send notification...: " + strTitle + " Msg: " + strMsg); NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); Intent intent;/* w w w . ja va 2s. c om*/ if (AppPreferences.getPrefs().getBoolean(commonVariables.KEY_IS_SELLER, false)) intent = new Intent(this, MainActivitySeller.class); else intent = new Intent(this, MainActivityBuyer.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); int requestID = (int) System.currentTimeMillis(); PendingIntent contentIntent = PendingIntent.getActivity(MyFirebaseMessagingService.this, requestID, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setContentTitle(strTitle) .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setStyle(new NotificationCompat.BigTextStyle().bigText(strMsg)).setContentText(strMsg) .setPriority(NotificationCompat.PRIORITY_MAX).setWhen(0).setVibrate(new long[] { 100, 100, 0, 0 }); mBuilder.setSmallIcon(R.drawable.ic_noti_fcm); try { Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification); r.play(); } catch (Exception e) { e.printStackTrace(); } mBuilder.setAutoCancel(true); if (!strMsg.contains("Your OTP is")) mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID++, mBuilder.build()); Log.d("TAGRK", "Notification sent successfully."); }
From source file:org.schabi.terminightor.AlarmItemDetailFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case READ_NFC_ID: if (resultCode == SetTagActivity.ID_RECEIVED) { byte[] nfcTagId = data.getByteArrayExtra(SetTagActivity.NFC_ID); returnedNfcTagId = nfcTagId; nfcTagIdView.setText(Arrays.toString(nfcTagId)); nfcTagLabelView.setVisibility(View.VISIBLE); }/*from w ww . ja v a 2 s.c o m*/ break; case SET_ALARM_TONE: if (data != null) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { alarm.setAlarmTone(uri.toString()); setAlarmToneButton .setText(RingtoneManager.getRingtone(getActivity(), uri).getTitle(getActivity())); } else { alarm.setAlarmTone(""); setAlarmToneButton.setText(getString(R.string.noneAlarmTone)); } } break; default: Log.e(TAG, "ERROR: request code not known"); } }
From source file:rikka.materialpreference.RingtonePreference.java
public void setValue(Uri uri) { if (uri != null) { Ringtone rng = RingtoneManager.getRingtone(getContext(), uri); if (rng != null) { setValue(rng.getTitle(getContext())); }/* w ww .j a va2 s .c o m*/ } else { setValue(mSummaryNone == null ? "" : mSummaryNone); } notifyChanged(); }
From source file:com.finchuk.clock2.alarms.ui.ExpandedAlarmViewHolder.java
private void bindRingtone() { int iconTint = Utils.getTextColorFromThemeAttr(getContext(), com.finchuk.clock2.R.attr.themedIconTint); Drawable ringtoneIcon = mRingtone.getCompoundDrawablesRelative()[0/*start*/]; ringtoneIcon = DrawableCompat.wrap(ringtoneIcon.mutate()); DrawableCompat.setTint(ringtoneIcon, iconTint); mRingtone.setCompoundDrawablesRelativeWithIntrinsicBounds(ringtoneIcon, null, null, null); String title = RingtoneManager.getRingtone(getContext(), getSelectedRingtoneUri()).getTitle(getContext()); mRingtone.setText(title);/*from ww w . ja v a 2 s . c o m*/ }
From source file:org.telegram.ui.ChatProfileActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); avatarUpdater.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == 15) { Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null;//www .j av a2s . c o m if (ringtone != null && parentActivity != null) { Ringtone rng = RingtoneManager.getRingtone(parentActivity, ringtone); if (rng != null) { name = rng.getTitle(parentActivity); rng.stop(); } } SharedPreferences preferences = parentActivity.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (name != null && ringtone != null) { editor.putString("sound_chat_" + chat_id, name); editor.putString("sound_chat_path_" + chat_id, ringtone.toString()); } else { editor.putString("sound_chat_" + chat_id, "NoSound"); editor.putString("sound_chat_path_" + chat_id, "NoSound"); } editor.commit(); listView.invalidateViews(); } } }
From source file:org.schabi.terminightor.AlarmItemDetailFragment.java
public void restoreItem(long id) { Context c = getContext();/*from w w w.j a v a 2 s.c o m*/ assert c != null; if (id >= 0) { try { alarm = Alarm.getFromCursorItem(AlarmDBOpenHelper.getAlarmDBOpenHelper(c).getReadableItem(id)); } catch (Exception e) { e.printStackTrace(); } restoreAlarm(alarm); timeValueSet = true; } else { alarm = new Alarm(); repeatCheckBox.setChecked(false); chooseDateView.setRepeatEnabled(false); displayNoTimeEntered(); Uri alarmToneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); alarm.setAlarmTone(alarmToneUri.toString()); try { setAlarmToneButton.setText(RingtoneManager.getRingtone(c, alarmToneUri).getTitle(c)); } catch (Exception e) { e.printStackTrace(); setAlarmToneButton.setText(c.getString(R.string.defaultRingTone)); } } }
From source file:org.schabi.terminightor.AlarmItemDetailFragment.java
private void restoreAlarm(Alarm alarm) { Context c = getContext();//from www . j a v a2 s.c o m setAlarmTimeView.setText(alarm.getTimeString(use24Hours)); timePickerDialog.updateTime(alarm.getHour(), alarm.getMinute()); setAlarmAMPMView.setText(alarm.getAMPMSuffix(use24Hours)); chooseDateView.setEnabledDays(alarm.getTerminightorStyledAlarmDays()); repeatCheckBox.setChecked(chooseDateView.isRepeatEnabled()); if (chooseDateView.isRepeatEnabled()) { chooseDateView.setVisibility(View.VISIBLE); } alarmLabelBox.setText(alarm.getName()); setAlarmToneButton.setText(RingtoneManager.getRingtone(c, Uri.parse(alarm.getAlarmTone())).getTitle(c)); vibrateCheckBox.setChecked(alarm.isVibrate()); if (alarm.getNfcTagId() != null && alarm.getNfcTagId().length != 0) { nfcTagLabelView.setVisibility(View.VISIBLE); nfcTagIdView.setText(Arrays.toString(alarm.getNfcTagId())); } }
From source file:com.gm.goldencity.util.Utils.java
/** * Play notification sound/* ww w . j av a2s .c o m*/ * * @param context Application context */ public static void playNotificationSound(Context context) { Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone r = RingtoneManager.getRingtone(context, notification); r.play(); }