List of usage examples for android.media Ringtone getTitle
public String getTitle(Context context)
From source file:Main.java
public static String getNameOfRingtone(Context context, Uri uri) { Ringtone ringtone = RingtoneManager.getRingtone(context, uri); return ringtone.getTitle(context); }
From source file:Main.java
public static String queryAudioName(Context context, Uri name) { String audioId;//from w w w. j ava 2 s .c om String uriName = name.toString(); uriName = uriName.substring(uriName.lastIndexOf("/") + 1); Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); int counter = cursor.getCount(); for (int j = 0; j < counter; j++) { audioId = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media._ID)); if (uriName.equals(audioId)) { uriName = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE)); } else { Ringtone ringtone = RingtoneManager.getRingtone(context, name); uriName = ringtone.getTitle(context); break; } cursor.moveToNext(); } cursor.close(); } else { try { Ringtone ringtone = RingtoneManager.getRingtone(context, name); uriName = ringtone.getTitle(context); } catch (Exception e) { return uriName; } } return uriName; }
From source file:org.isoron.uhabits.utils.RingtoneUtils.java
@Nullable public static String getRingtoneName(Context context) { try {//from w w w . j a v a 2 s . c o m 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 w w w. ja v a 2 s . c o 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.apache.cordova.ringtonepicker.RingtonePicker.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("customPlugin", "Calling onActivityResult"); if (resultCode == Activity.RESULT_OK && requestCode == 5) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); Ringtone ringtone = RingtoneManager.getRingtone(this.cordova.getActivity(), uri); String title = ringtone.getTitle(this.cordova.getActivity()); Log.d("customPlugin", "I picked this ringtone " + uri); Log.d("customPlugin", "I picked this ringtone title" + title); if (uri != null) { Log.d("customPlugin", "Setting ringtone to " + notification_uri); String returnText = "{\"ringtone\": {\"title\": \"" + title + "\",\"uri\": \"" + uri + "\"}}"; PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, returnText); pluginResult.setKeepCallback(true); this.callbackContext.sendPluginResult(pluginResult); }/*ww w . ja v a 2s. c o m*/ } }
From source file:org.getlantern.firetweet.preference.RingtonePreference.java
private void loadRingtones(final Context context) { final RingtoneManager manager = new RingtoneManager(context); manager.setType(RingtoneManager.TYPE_NOTIFICATION); final Cursor cur = manager.getCursor(); cur.moveToFirst();//ww w. j a v a2 s . c om final int count = cur.getCount(); mRingtones = new Ringtone[count + 1]; mEntries = new String[count + 1]; mValues = new String[count + 1]; final Uri default_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); final Ringtone default_ringtone = RingtoneManager.getRingtone(context, default_uri); mRingtones[0] = default_ringtone; mEntries[0] = context.getString(R.string.default_ringtone); mValues[0] = default_uri.toString(); for (int i = 0; i < count; i++) { final Ringtone ringtone = manager.getRingtone(i); mRingtones[i + 1] = ringtone; mEntries[i + 1] = ringtone.getTitle(context); mValues[i + 1] = manager.getRingtoneUri(i).toString(); } setEntries(mEntries); setEntryValues(mValues); cur.close(); }
From source file:monakhv.android.samlib.SamlibPreferencesActivity.java
private void updateRingtoneSummary(RingtonePreference preference, Uri ringtoneUri) { Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri); if (ringtone != null) { preference.setSummary(ringtone.getTitle(this)); } else {/*from www .j a v a 2 s. com*/ preference.setSummary(getString(R.string.pref_no_sound)); } }
From source file:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java
/** * Set the preference's value(s) as its summary. *//*www . ja v a 2 s . co m*/ protected void setSummary(Preference pref) { SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (pref instanceof RingtonePreference) { String val = prefs.getString(pref.getKey(), null); if (!TextUtils.isEmpty(val)) { Ringtone tone = RingtoneManager.getRingtone(a, Uri.parse(val)); if (tone != null) { pref.setSummary(tone.getTitle(a)); } } else { pref.setSummary(R.string.none); } } else if (pref instanceof MultiSelectListPreference) { Set<String> vals = prefs.getStringSet(pref.getKey(), null); if (vals != null) { if (!vals.isEmpty()) { MultiSelectListPreference multi = (MultiSelectListPreference) pref; IntList indexList = new ArrayIntList(vals.size()); for (String val : vals) { // find selected entry indexes int i = multi.findIndexOfValue(val); if (i >= 0) { indexList.add(i); } } int[] indexes = indexList.toArray(); Arrays.sort(indexes); // to display in same order as dialog pref.setSummary(TextUtils.join(getString(R.string.delimiter), Elements.slice(multi.getEntries(), indexes))); } else { pref.setSummary(R.string.none); } } } else if (pref instanceof EditTextPreference) { pref.setSummary(prefs.getString(pref.getKey(), null)); } else if (pref.getClass() == Preference.class) { String val = prefs.getString(pref.getKey(), null); if (!TextUtils.isEmpty(val)) { // don't clear existing summary pref.setSummary(val); } } }
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())); }/*from w ww . j av a 2 s .c o m*/ } else { setValue(mSummaryNone == null ? "" : mSummaryNone); } notifyChanged(); }
From source file:com.wizardsofm.deskclock.data.TimerModel.java
/** * @return the title of the ringtone that is played for all timers *//*from w w w . j a v a2 s . co m*/ String getTimerRingtoneTitle() { if (mTimerRingtoneTitle == null) { if (isTimerRingtoneSilent()) { // Special case: no ringtone has a title of "Silent". mTimerRingtoneTitle = mContext.getString(com.wizardsofm.deskclock.R.string.silent_ringtone_title); } else { final Uri defaultUri = getDefaultTimerRingtoneUri(); final Uri uri = getTimerRingtoneUri(); if (defaultUri.equals(uri)) { // Special case: default ringtone has a title of "Timer Expired". mTimerRingtoneTitle = mContext .getString(com.wizardsofm.deskclock.R.string.default_timer_ringtone_title); } else { final Ringtone ringtone = RingtoneManager.getRingtone(mContext, uri); mTimerRingtoneTitle = ringtone.getTitle(mContext); } } } return mTimerRingtoneTitle; }