本文整理汇总了Java中android.media.RingtoneManager.getRingtone方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.getRingtone方法的具体用法?Java RingtoneManager.getRingtone怎么用?Java RingtoneManager.getRingtone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RingtoneManager
的用法示例。
在下文中一共展示了RingtoneManager.getRingtone方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRingtoneTitle
import android.media.RingtoneManager; //导入方法依赖的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;
}
示例2: getRingtoneName
import android.media.RingtoneManager; //导入方法依赖的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: initSeekBar
import android.media.RingtoneManager; //导入方法依赖的package包/类
private void initSeekBar(SeekBar seekBar, Uri defaultUri) {
seekBar.setMax(mAudioManager.getStreamMaxVolume(mStreamType));
mOriginalStreamVolume = mAudioManager.getStreamVolume(mStreamType);
seekBar.setProgress(mOriginalStreamVolume);
seekBar.setOnSeekBarChangeListener(this);
// TODO: removed in MM, find different approach
mContext.getContentResolver().registerContentObserver(
System.getUriFor("volume_ring"),
false, mVolumeObserver);
if (defaultUri == null) {
if (mStreamType == AudioManager.STREAM_RING) {
defaultUri = Settings.System.DEFAULT_RINGTONE_URI;
} else if (mStreamType == AudioManager.STREAM_NOTIFICATION) {
defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
} else {
defaultUri = Settings.System.DEFAULT_ALARM_ALERT_URI;
}
}
mRingtone = RingtoneManager.getRingtone(mContext, defaultUri);
if (mRingtone != null) {
mRingtone.setStreamType(mStreamType);
}
}
示例4: onInitSample
import android.media.RingtoneManager; //导入方法依赖的package包/类
private void onInitSample() {
mRingtone = RingtoneManager.getRingtone(getContext(),
Settings.System.DEFAULT_RINGTONE_URI);
if (mRingtone != null) {
mRingtone.setStreamType(AudioManager.STREAM_RING);
mRingtone.setAudioAttributes(
new AudioAttributes.Builder(mRingtone.getAudioAttributes())
.setFlags(AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY |
AudioAttributes.FLAG_BYPASS_MUTE)
.build());
}
}
示例5: createNotif
import android.media.RingtoneManager; //导入方法依赖的package包/类
public void createNotif() {
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
String eventName = eventsForNotif[0];
if (counterForCurrentEventsForNotif > 1) {
for (int i = 1; i < counterForEventsForNotif; i++) {
if (i == counterForCurrentEventsForNotif - 1)
eventName = eventName + " and " + currentEventsForNotif[i];
else
eventName = eventName + ", " + currentEventsForNotif[i];
}
}
Uri notifRing = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone ringtone =RingtoneManager.getRingtone(context, notifRing);
ringtone.play();
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(500);
Log.d("alarm","ture");
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_calendar)
.setContentTitle("Trinity")
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setContentText(eventName + " scheduled for today.");
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int mNotifId = 1;
manager.notify(mNotifId, builder.build());
}
示例6: getSoundName
import android.media.RingtoneManager; //导入方法依赖的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);
}
示例7: notifyNewMensage
import android.media.RingtoneManager; //导入方法依赖的package包/类
private void notifyNewMensage(Chat chat){
notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(getActivity(), ChatActivity.class);
intent.putExtra("name",chat.getName());
intent.putExtra("email", Base64Custom.decodeBase64(chat.getUserId()));
PendingIntent pendingIntent = PendingIntent.getActivity(getContext(),0, intent,0);
NotificationCompat.Builder builder = new android.support.v7.app.NotificationCompat.Builder(getContext());
builder.setContentIntent(pendingIntent);
builder.setTicker("Nova mensagem de "+chat.getName());
builder.setContentTitle("Mensagem de "+chat.getName());
builder.setContentText(chat.getMensageValue());
builder.setSmallIcon(R.drawable.ic_chat);
builder.setVibrate(new long[] { 200, 200, 200, 200, 200 });
Notification notification = builder.build();
notificationManager.notify(Integer.parseInt(chat.getUserId().replaceAll("[^0-9]", "")), notification);
try{
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone ringtone = RingtoneManager.getRingtone(getContext(),uri);
ringtone.play();
}catch (Exception e){
}
}
示例8: onActivityResultFragment
import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
return;
}
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();
}
}
示例9: onCreate
import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.other_sound_settings);
mContext = getActivity();
// power state change notification sounds
mPowerSoundsVibrate = (SwitchPreference) findPreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
mPowerSoundsVibrate.setChecked(CMSettings.Global.getInt(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) != 0);
Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator == null || !vibrator.hasVibrator()) {
removePreference(KEY_POWER_NOTIFICATIONS_VIBRATE);
}
mPowerSoundsRingtone = findPreference(KEY_POWER_NOTIFICATIONS_RINGTONE);
String currentPowerRingtonePath = CMSettings.Global.getString(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE);
// set to default notification if we don't yet have one
if (currentPowerRingtonePath == null) {
currentPowerRingtonePath = System.DEFAULT_NOTIFICATION_URI.toString();
CMSettings.Global.putString(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, currentPowerRingtonePath);
}
// is it silent ?
if (currentPowerRingtonePath.equals(POWER_NOTIFICATIONS_SILENT_URI)) {
mPowerSoundsRingtone.setSummary(
getString(R.string.power_notifications_ringtone_silent));
} else {
final Ringtone ringtone =
RingtoneManager.getRingtone(getActivity(), Uri.parse(currentPowerRingtonePath));
if (ringtone != null) {
mPowerSoundsRingtone.setSummary(ringtone.getTitle(getActivity()));
}
}
for (SettingPref pref : PREFS) {
pref.init(this);
}
}
示例10: SinchAudioCall
import android.media.RingtoneManager; //导入方法依赖的package包/类
public SinchAudioCall(Context context)
{
callClient = ConfigureSinch.retrieveSinchClient().getCallClient();
mUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
mRingtone = RingtoneManager.getRingtone(context, mUri);
}
示例11: onPreferenceChange
import android.media.RingtoneManager; //导入方法依赖的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);
String title = index >= 0 ? String.valueOf(listPreference.getEntries()[index]) : "";
//Exibir o tempo total de funcionamento do registrador depois do ultimo reset.
if (OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_OFTEN_LOGGER_RESET.equals(preference.getKey())){
Context context = preference.getContext();
long durationLoggerRunning = preference.getSharedPreferences().getLong(OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_DURATION_LOGGER_RUNNING,0);
preference.setTitle(String.format(context.getString(R.string.pref_title_energy_use_sync_often_logger_reset), title));
preference.setSummary(String.format(context.getString(R.string.pref_summary_energy_use_sync_often_logger_reset), OhaHelper.convertMillisToHours(durationLoggerRunning)));
} else {
// Set the summary to reflect the new value.
preference.setSummary(title);
}
} else if (preference instanceof RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
if (!TextUtils.isEmpty(stringValue)) {
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;
}
示例12: onPreferenceChange
import android.media.RingtoneManager; //导入方法依赖的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: onActivityResultFragment
import android.media.RingtoneManager; //导入方法依赖的package包/类
@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;
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();
}
}
示例14: onSuccess
import android.media.RingtoneManager; //导入方法依赖的package包/类
@Override
public void onSuccess(AppApi.Action method, Object obj) {
super.onSuccess(method, obj);
switch (method) {
case POST_IMAGE_PROJECTION_JSON:
dismissProLoadingDialog();
if(obj instanceof ImageProResonse) {
ImageProResonse proResonseInfo = (ImageProResonse) obj;
mProjectId = proResonseInfo.getProjectId();
ProjectionManager.getInstance().setProjectId(mProjectId);
}
if (small==1){
small = 0;
switch (mCurrentProType) {
case TYPE_PRO_SINGLE:
ProjectionManager.getInstance().setSlideStatus(false);
if(mProjectionService!=null) {
mProjectionService.stopQuerySeek();
mProjectionService.stopSlide();
}
compressFirstImage(mSingleInfo);
break;
case TYPE_PRO_SLIDES:
if(mProjectionService!=null) {
mProjectionService.stopQuerySeek();
mProjectionService.stopSlide();
}
if(mSelectedList.size()>0) {
compressFirstImage(mSelectedList.get(0));
}
break;
}
handleProSuccess();
return;
}
break;
case POST_LOCAL_VIDEO_PRO_JSON:
dismissProLoadingDialog();
mLoadingDialog.dismiss();
if(obj instanceof LocalVideoProPesponse) {
LocalVideoProPesponse response = (LocalVideoProPesponse) obj;
projectId = response.getProjectId();
ProjectionManager.getInstance().setProjectId(projectId);
// prepareSuccess(prepareResponseVo);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(SavorApplication.getInstance(), notification);
r.play();
dismissLoadingDialog();
LocalVideoProAcitvity.startLocalVideoProActivity(this,mCurrentVideoInfo,true,projectId);
resetNormalState();
if(mProjectionService!=null) {
mProjectionService.stopSlide();
}
ProjectionManager.getInstance().setSlideStatus(false);
}
break;
}
}