本文整理汇总了Java中android.media.Ringtone.getTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Ringtone.getTitle方法的具体用法?Java Ringtone.getTitle怎么用?Java Ringtone.getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.Ringtone
的用法示例。
在下文中一共展示了Ringtone.getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPowerNotificationRingtone
import android.media.Ringtone; //导入方法依赖的package包/类
private void setPowerNotificationRingtone(Intent intent) {
final Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
final String toneName;
final String toneUriPath;
if ( uri != null ) {
final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
toneName = ringtone.getTitle(getActivity());
toneUriPath = uri.toString();
} else {
// silent
toneName = getString(R.string.power_notifications_ringtone_silent);
toneUriPath = POWER_NOTIFICATIONS_SILENT_URI;
}
mPowerSoundsRingtone.setSummary(toneName);
CMSettings.Global.putString(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, toneUriPath);
}
示例2: getRingtoneName
import android.media.Ringtone; //导入方法依赖的package包/类
/**
* Get the title of the ringtone from the uri of ringtone.
*
* @param context instance of the caller
* @param uri uri of the tone to search
* @return title of the tone or return null if no tone found.
*/
@Nullable
public static String getRingtoneName(@NonNull Context context,
@NonNull Uri uri) {
Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
if (ringtone != null) {
return ringtone.getTitle(context);
} else {
Cursor cur = context
.getContentResolver()
.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Media.TITLE},
MediaStore.Audio.Media._ID + " =?",
new String[]{uri.getLastPathSegment()},
null);
String title = null;
if (cur != null) {
title = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.TITLE));
cur.close();
}
return title;
}
}
示例3: getRingtoneName
import android.media.Ringtone; //导入方法依赖的package包/类
@NonNull public static String getRingtoneName(@NonNull Context context, @Nullable Uri uri) {
String title = context.getString(R.string.sound_chooser_summary);
if (uri != null) {
Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
if (ringtone != null) {
return ringtone.getTitle(context);
} else {
try (Cursor cur = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Audio.Media.TITLE}, MediaStore.Audio.Media._ID + " =?",
new String[]{uri.getLastPathSegment()}, null)) {
if (cur != null) {
title = cur.getString(1);
if (InputHelper.isEmpty(title)) {
title = cur.getString(cur.getColumnIndex(MediaStore.Audio.Media.TITLE));
}
}
} catch (Exception ignored) {}
}
}
return title;
}
示例4: getRingtoneTitle
import android.media.Ringtone; //导入方法依赖的package包/类
private String getRingtoneTitle() {
DebugLog.logMethod();
String ringtoneUri = getPreferenceManager().getSharedPreferences().getString(
KEY_NOTIFICATION_RINGTONE,
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString()
);
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(ringtoneUri));
String ringtoneTitle = ringtone.getTitle(getActivity());
// Prevent memory leaks
ringtone.stop();
return ringtoneTitle;
}
示例5: setRingname
import android.media.Ringtone; //导入方法依赖的package包/类
/**
* Set the Ring tone that is selected for the disconnect Hiro or Find phone
* through.
*
* @param model
*/
private void setRingname(DeviceInfoModel model) {
String phoneRing = preferences.getString("PhoneRing", "");
String disRing = model.getDisconnectRing();
if (disRing != null && !disRing.equalsIgnoreCase("")) {
Uri uri = Uri.parse(disRing);
Ringtone ringtone = RingtoneManager.getRingtone(
SettingsActivity.this, uri);
String name = ringtone.getTitle(SettingsActivity.this);
if (name != null && !name.equalsIgnoreCase(""))
txtDisconnectRingtone.setText(name);
}
if (phoneRing != null && !phoneRing.equalsIgnoreCase("")) {
Uri uri1 = Uri.parse(phoneRing);
Ringtone ringtone1 = RingtoneManager.getRingtone(
SettingsActivity.this, uri1);
String name1 = ringtone1.getTitle(SettingsActivity.this);
txtPhoneRing.setText(name1);
}
}
示例6: shortPath
import android.media.Ringtone; //导入方法依赖的package包/类
public String shortPath(String path) {
if(isPathRingtone(mContext, path)) {
Ringtone ringtone = RingtoneManager.getRingtone(mContext, Uri.parse(path));
// Just verified that the ringtone exists... not checking for null
return ringtone.getTitle(mContext);
}
if(path == null) {
return "";
}
if(path.length() == 0) {
return "xDrip Default";
}
String[] segments = path.split("/");
if (segments.length > 1) {
return segments[segments.length - 1];
}
return path;
}
示例7: updateRingtoneSummary
import android.media.Ringtone; //导入方法依赖的package包/类
private void updateRingtoneSummary(PreferenceScreen preferenceScreen) {
String name = getString(R.string.pref_ringtone_none);
String value = Preferences.getString(mContext, Preferences.NOTIFICATION_RINGTONE, null);
if (!TextUtils.isEmpty(value)) {
Uri ringtoneUri = Uri.parse(value);
Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri);
if (ringtone != null) {
name = ringtone.getTitle(mContext);
}
}
preferenceScreen.findPreference(Preferences.NOTIFICATION_RINGTONE).setSummary(name);
preferenceScreen.findPreference(Preferences.NOTIFICATION_RINGTONE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String v = (String) newValue;
preference.setSummary(v);
return true;
}
});
}
示例8: shortPath
import android.media.Ringtone; //导入方法依赖的package包/类
public String shortPath(String path) {
if(path != null) {
if(path.length() == 0) {
return "xDrip Default";
}
Ringtone ringtone = RingtoneManager.getRingtone(mContext, Uri.parse(path));
if (ringtone != null) {
return ringtone.getTitle(mContext);
} else {
String[] segments = path.split("/");
if (segments.length > 1) {
return segments[segments.length - 1];
}
}
}
return "";
}
示例9: getSoundTitle
import android.media.Ringtone; //导入方法依赖的package包/类
private String getSoundTitle() {
Context context = manager.getContext();
String soundPref = settings.getString("sound", "Nuke");
if (sounds == null) {
sounds = context.getResources()
.getStringArray(R.array.sounds_array);
soundsRaw = context.getResources().getStringArray(
R.array.sounds_array_format);
}
if (!manager.arrayContainsString(sounds, soundPref)) {
Uri ringtoneUri = Uri.parse(soundPref);
Ringtone ringtone = RingtoneManager.getRingtone(context,
ringtoneUri);
soundPref = ringtone.getTitle(context);
}
return soundPref;
}
示例10: updateRingtoneSummary
import android.media.Ringtone; //导入方法依赖的package包/类
public void updateRingtoneSummary(String tone) {
String template = getString(R.string.choose_notification_tone_summary);
if (tone.equals("")) {
tone = getString(R.string.silent);
} else {
Uri uriTone = Uri.parse(tone);
Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), uriTone);
if (ringtone == null) {
tone = getString(R.string.default_tone);
} else {
tone = ringtone.getTitle(getApplicationContext());
}
}
String result = String.format(template, tone);
ringTone.setSummary(result);
}
示例11: onRingtoneSelected
import android.media.Ringtone; //导入方法依赖的package包/类
private void onRingtoneSelected(String uriString) {
mContactData.ringtoneUri = uriString;
String buttonText = "No custom ringtone";
if (SILENT.equals(uriString)) {
buttonText = "Force silent";
} else {
try {
Uri uri = Uri.parse(uriString);
if (uri != null && !GLOBAL.equals(uriString)) {
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
buttonText = ringtone.getTitle(getActivity());
ringtone.stop();
}
} catch (Exception e) {
Log.e(TAG, "onRingtoneSelected: error", e);
}
}
mChooseRingtoneButton.setText(buttonText);
}
示例12: onPreferenceChange
import android.media.Ringtone; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else if (preference instanceof RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
if (TextUtils.isEmpty(stringValue)) {
// Empty values correspond to 'silent' (no ringtone).
preference.setSummary(R.string.pref_ringtone_silent);
} else {
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null) {
// Clear the summary if there was a lookup error.
preference.setSummary(null);
} else {
// Set the summary to reflect the new ringtone display
// name.
String name = ringtone.getTitle(preference.getContext());
preference.setSummary(name);
}
}
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例13: getSoundName
import android.media.Ringtone; //导入方法依赖的package包/类
public String getSoundName(Context context) {
if (sound == null) {
return context.getString(R.string.notification_options_off);
}
Uri uri = Uri.parse(sound);
if (Settings.System.DEFAULT_NOTIFICATION_URI.equals(uri)) {
return context.getString(R.string.notification_options_default);
}
Ringtone ringtone = RingtoneManager.getRingtone(context, uri);
return ringtone != null ? ringtone.getTitle(context) : context.getString(R.string.notification_options_off);
}
示例14: onPreferenceChange
import android.media.Ringtone; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
PushService.cancelPushService(AppContext.getContext());
PushService.setServiceAlarm(AppContext.getContext());
} else if (preference instanceof RingtonePreference) {
if (TextUtils.isEmpty(stringValue)) {
preference.setSummary(R.string.pref_ringtone_silent);
} else {
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null) {
preference.setSummary(null);
} else {
String name = ringtone.getTitle(preference.getContext());
preference.setSummary(name);
}
}
} else {
preference.setSummary(stringValue);
}
return true;
}
示例15: onPreferenceChange
import android.media.Ringtone; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else if (preference instanceof RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null) {
// Clear the summary if there was a lookup error.
preference.setSummary(null);
} else {
// Set the summary to reflect the new ringtone display
// name.
String name = ringtone.getTitle(preference.getContext());
preference.setSummary(name);
}
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}