List of usage examples for android.media Ringtone stop
public void stop()
From source file:org.isoron.uhabits.utils.RingtoneUtils.java
@Nullable public static String getRingtoneName(Context context) { try {/*from w w w .j a v a2s . com*/ Uri ringtoneUri = getRingtoneUri(context); String ringtoneName = context.getResources().getString(R.string.none); if (ringtoneUri != null) { Ringtone ringtone = getRingtone(context, ringtoneUri); if (ringtone != null) { ringtoneName = ringtone.getTitle(context); ringtone.stop(); } } return ringtoneName; } catch (RuntimeException e) { e.printStackTrace(); return null; } }
From source file:org.isoron.uhabits.helpers.ReminderHelper.java
@Nullable public static String getRingtoneName(Context context) { try {/*from ww w .jav a2 s . co m*/ Uri ringtoneUri = getRingtoneUri(context); String ringtoneName = context.getResources().getString(R.string.none); if (ringtoneUri != null) { Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri); if (ringtone != null) { ringtoneName = ringtone.getTitle(context); ringtone.stop(); } } return ringtoneName; } catch (RuntimeException e) { e.printStackTrace(); return null; } }
From source file:org.sipdroid.sipua.ui.Receiver.java
public static void stopRingtone() { if (v != null) v.cancel();/* ww w.jav a2 s .c o m*/ if (Receiver.oRingtone != null) { Ringtone ringtone = Receiver.oRingtone; oRingtone = null; ringtone.stop(); } }
From source file:org.getlantern.firetweet.preference.RingtonePreference.java
@Override protected void onDialogClosed(final boolean positiveResult) { final Ringtone ringtone = getSelectedRingtone(); if (ringtone != null && ringtone.isPlaying()) { ringtone.stop(); }// ww w . j av a2 s . c om if (positiveResult && mSelectedItem >= 0 && mSelectedItem < mValues.length) { if (callChangeListener(mValues[mSelectedItem])) { persistString(mValues[mSelectedItem]); } } }
From source file:org.getlantern.firetweet.preference.RingtonePreference.java
@Override protected void onPrepareDialogBuilder(final Builder builder) { loadRingtones(getContext());//from w w w. java2 s . c o m setSelectedItem(ArrayUtils.indexOf(mValues, getPersistedString(null))); builder.setSingleChoiceItems(getEntries(), getSelectedItem(), new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { setSelectedItem(which); final Ringtone ringtone = getSelectedRingtone(); if (ringtone.isPlaying()) { ringtone.stop(); } ringtone.play(); } }); }
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;/* w w w .jav a 2 s .c om*/ 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.telegram.ui.ProfileNotificationsActivity.java
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; }// w ww .j a va 2 s .c om Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); if (rng != null) { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } rng.stop(); } } SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == 12) { if (name != null) { editor.putString("sound_" + dialog_id, name); editor.putString("sound_path_" + dialog_id, ringtone.toString()); } else { editor.putString("sound_" + dialog_id, "NoSound"); editor.putString("sound_path_" + dialog_id, "NoSound"); } } editor.commit(); listView.invalidateViews(); } }
From source file:org.telegram.ui.NotificationsSettingsActivity.java
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null;// w ww . ja va 2 s . c o m if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); if (rng != null) { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } rng.stop(); } } SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == messageSoundRow) { if (name != null && ringtone != null) { editor.putString("GlobalSound", name); editor.putString("GlobalSoundPath", ringtone.toString()); } else { editor.putString("GlobalSound", "NoSound"); editor.putString("GlobalSoundPath", "NoSound"); } } else if (requestCode == groupSoundRow) { if (name != null && ringtone != null) { editor.putString("GroupSound", name); editor.putString("GroupSoundPath", ringtone.toString()); } else { editor.putString("GroupSound", "NoSound"); editor.putString("GroupSoundPath", "NoSound"); } } editor.commit(); listView.invalidateViews(); } }