当前位置: 首页>>代码示例>>Java>>正文


Java Ringtone.getTitle方法代码示例

本文整理汇总了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);
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:21,代码来源:OtherSoundSettings.java

示例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;
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-ringtone-picker,代码行数:31,代码来源:RingtoneUtils.java

示例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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:22,代码来源:FileHelper.java

示例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;
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:14,代码来源:SettingsFragment.java

示例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);
	}

}
 
开发者ID:JayconSystems,项目名称:Hiro-App-Android,代码行数:31,代码来源:SettingsActivity.java

示例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;
}
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:xDrip-Experimental,代码行数:19,代码来源:EditAlertActivity.java

示例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;
        }
    });
}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:21,代码来源:SettingsFragment.java

示例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 "";
    }
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:NightWatch,代码行数:19,代码来源:AlertList.java

示例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;
	}
 
开发者ID:LeonardoCardoso,项目名称:Silence-Please,代码行数:23,代码来源:PSettingsOptionsFragment.java

示例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);
}
 
开发者ID:thunderace,项目名称:newtifry,代码行数:18,代码来源:SourceNotificationPreferenceActivity.java

示例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);
}
 
开发者ID:andreiciubotariu,项目名称:contact-notifier,代码行数:20,代码来源:ColorVibrateDialog.java

示例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;
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:46,代码来源:SettingsActivity.java

示例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);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:12,代码来源:NotificationOptions.java

示例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;
}
 
开发者ID:Yuijam,项目名称:droidfan,代码行数:38,代码来源:SettingsActivity.java

示例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;
}
 
开发者ID:NandagopalR,项目名称:Android-Audio-Recorder,代码行数:39,代码来源:SettingsActivity.java


注:本文中的android.media.Ringtone.getTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。