Best code examples for Android Ringtone class (android.media.Ringtone)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Ringtone class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Ringtone examples from Open Source projects
This code example shows how to use the following methods: isPlaying, stop
            ringtone.play();
        } 
    } 
 
    private void stopAnyPlayingRingtone() { 
        if (defaultRingtone != null && defaultRingtone.isPlaying()) {
            defaultRingtone.stop();
        } 
        if (ringtoneManager != null) {
            ringtoneManager.stopPreviousRingtone();
        } 
    } 
} 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: isPlaying, play, stop
		builder.setSingleChoiceItems(getEntries(), getSelectedItem(), new OnClickListener() {
			@Override 
			public void onClick(final DialogInterface dialog, final int which) {
				setSelectedItem(which);
				final Ringtone ringtone = getSelectedRingtone();
				if (ringtone.isPlaying()) {
					ringtone.stop();
				} 
				ringtone.play();
			} 
		}); 
	} 
 
	private void loadRingtones(final Context context) {
		final RingtoneManager manager = new RingtoneManager(context);
		manager.setType(RingtoneManager.TYPE_NOTIFICATION);
		final Cursor cur = manager.getCursor();
		cur.moveToFirst();
		final int count = cur.getCount();
		mRingtones = new ArrayList<Ringtone>(count);
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: play, setStreamType
        try { 
            if (mRingerPlayer != null) {
                mRingerPlayer.stop();
            } 
            mRingerPlayer = RingtoneManager.getRingtone(mContext, uri);
            mRingerPlayer.setStreamType(streamType);
            mRingerPlayer.play();
        } catch (Exception e) {
            Log.e(TAG, "error ringing", e);
        } 
    } 
 
    private synchronized void ringOutgoing(Uri uri) {
        int streamType = AudioManager.STREAM_VOICE_CALL;
        ring(uri, streamType);
    } 
 
    /* 
     * private synchronized void playNotification() { Uri notification = 
     * RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: isPlaying, stop
 
    public void term() 
        { 
        if (rt != null)
            { 
            if (rt.isPlaying())
                rt.stop();
            } 
 
        if (toast != null)
            toast.cancel();
        } 
 
    public void run () 
        { 
        String sText =(((lcv++ % 2) == 0)  ? "Help me!" : "I've fallen down!" );
        toast.setText(sText);
        toast.show();
        if (rt != null)
            rt.play();
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: isPlaying, stop
        dialog.show();
        return this;
    } 
 
    private void stopAnyPlayingRingtone() { 
        if (defaultRingtone != null && defaultRingtone.isPlaying()) {
            defaultRingtone.stop();
        } 
        if (ringtoneManager != null) {
            ringtoneManager.stopPreviousRingtone();
        } 
    } 
} 
Full Snippet Info
6
CodeRank
Related Android Ringtone Questions & Answers:
See Code Examples for Android Ringtone Methods: