use of android.media.Ringtone in project kcanotify by antest1.
the class MainPreferenceFragment method getRingtoneTitle.
private String getRingtoneTitle(Uri ringtoneUri) {
Log.e("KCA", "uri: " + (ringtoneUri != null ? ringtoneUri.toString() : ""));
Log.e("KCA", "valid: " + checkActivityValid());
if (ringtoneUri != null && checkActivityValid()) {
getActivity().grantUriPermission(BuildConfig.APPLICATION_ID, ringtoneUri, FLAG_GRANT_READ_URI_PERMISSION);
Ringtone ringtone = RingtoneManager.getRingtone(getContext(), ringtoneUri);
return ringtone.getTitle(getContext());
} else {
return getStringWithLocale(R.string.settings_string_silent);
}
}
use of android.media.Ringtone in project Gadgetbridge by Freeyourgadget.
the class NotificationManagementActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == RINGTONE_REQUEST_CODE && intent != null) {
if (intent.getExtras().getParcelable(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) != null) {
Uri uri = intent.getExtras().getParcelable(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Ringtone r = RingtoneManager.getRingtone(this, uri);
findPreference(GBPrefs.PING_TONE).setSummary(r.toString());
PreferenceManager.getDefaultSharedPreferences(this).edit().putString(GBPrefs.PING_TONE, uri.toString()).apply();
findPreference(GBPrefs.PING_TONE).setSummary(r.getTitle(this));
}
}
}
use of android.media.Ringtone in project chefly_android by chef-ly.
the class AlarmReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String name = intent.getStringExtra("name");
Toast.makeText(context, "Alarm!!! " + name, Toast.LENGTH_LONG).show();
timer.onTimerFinished(name);
// TODO check if ringtone is null
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
final Ringtone r = RingtoneManager.getRingtone(context, notification);
r.play();
Log.d(TAG, "Alarm Alarm Alarm");
Handler h = new Handler();
h.postDelayed(new Runnable() {
@Override
public void run() {
r.stop();
}
}, 5000);
}
use of android.media.Ringtone in project android-aosp-mms by slvn.
the class MessagingPreferenceActivity method setRingtoneSummary.
private void setRingtoneSummary(String soundValue) {
Uri soundUri = TextUtils.isEmpty(soundValue) ? null : Uri.parse(soundValue);
Ringtone tone = soundUri != null ? RingtoneManager.getRingtone(this, soundUri) : null;
mRingtonePref.setSummary(tone != null ? tone.getTitle(this) : getResources().getString(R.string.silent_ringtone));
}
Aggregations