Code example for Ringtone

Methods: isPlaying, play, setStreamType

0
 
        @Override 
        public void onStopTrackingTouch(SeekBar seekBar) { 
            int index = seekBar.getId(); 
            if (!isSamplePlaying()) { 
                mRingtone.setStreamType(SEEKBAR_TYPE[index]); 
                startSample(); 
            } 
        } 
    }; 
 
    public static boolean isVoiceCapable(Context context) {
        TelephonyManager telephony =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return telephony != null && telephony.isVoiceCapable();
    } 
 
    private boolean isSamplePlaying() { 
        return mRingtone != null && mRingtone.isPlaying();
    } 
 
    private void startSample() { 
        if (mRingtone != null) {
            mRingtone.play();
        } 
    } 
 
    private void stopSample() { 
        if (mRingtone != null) {