Search in sources :

Example 46 with Ringtone

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);
    }
}
Also used : Ringtone(android.media.Ringtone)

Example 47 with Ringtone

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));
        }
    }
}
Also used : Ringtone(android.media.Ringtone) Uri(android.net.Uri)

Example 48 with Ringtone

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);
}
Also used : Ringtone(android.media.Ringtone) Handler(android.os.Handler) Uri(android.net.Uri)

Example 49 with Ringtone

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));
}
Also used : Ringtone(android.media.Ringtone) Uri(android.net.Uri)

Aggregations

Ringtone (android.media.Ringtone)49 Uri (android.net.Uri)33 ContentResolver (android.content.ContentResolver)8 Intent (android.content.Intent)6 AudioManager (android.media.AudioManager)4 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 SQLiteException (android.database.sqlite.SQLiteException)2 RingtoneManager (android.media.RingtoneManager)2 RingtonePreference (android.preference.RingtonePreference)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 ArrayList (java.util.ArrayList)2 CallNotificationBuilder (org.thoughtcrime.securesms.webrtc.CallNotificationBuilder)2 SharedPreferences (android.content.SharedPreferences)1 Handler (android.os.Handler)1 Vibrator (android.os.Vibrator)1 Preference (android.support.v7.preference.Preference)1