當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。