Android RingtoneManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android RingtoneManager class.

This code example shows how to use the following methods:getCursor, inferStreamType, setIncludeDrm, setType
9
CodeRank
This code example shows how to use the following methods:getCursor, inferStreamType, setIncludeDrm, setType
7
CodeRank
This code example shows how to use the following methods:getSystemService, getRingtone
        } 
    } 
 
    private void initAudio() { 
        mAudioManager = (AudioManager) mContext
                .getSystemService(Context.AUDIO_SERVICE);
    } 
 
    private synchronized void ringIncoming() { 
        Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        int ringerMode = mAudioManager.getRingerMode();
        mVibrator = (Vibrator) mContext
                .getSystemService(Context.VIBRATOR_SERVICE);
        if (mCallInProgress) {
            // Notify with single vibrate. 
            mVibrator.vibrate((long) 200);
        } else { 
            if (AudioManager.RINGER_MODE_NORMAL == ringerMode) {
                mAudioManager.setMode(AudioManager.MODE_RINGTONE);
                ring(uri, AudioManager.STREAM_RING);

7
CodeRank
This code example shows how to use the following methods:getCursor, inferStreamType, setIncludeDrm, setType
6
CodeRank
This code example shows how to use the following methods:getCursor, setIncludeDrm, setType
  class BuiltinToneCursor extends ToneCursor 
  { 
    private RingtoneManager mRingtoneManager;
    public BuiltinToneCursor(int ringtone_type) { 
      init(); 
      mRingtoneManager = new RingtoneManager(mContext);
      mRingtoneManager.setType(ringtone_type);
      mRingtoneManager.setIncludeDrm(true);
      mCursor = mRingtoneManager.getCursor();
    } 
    public Tone cacheTone(int position) {
      mCursor.moveToPosition(position);
      Tone tone = new Tone();
      tone.name = mCursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
      tone.uri = mRingtoneManager.getRingtoneUri(position);
      return tone;
    } 
  } 
 
  class MediaToneCursor extends ToneCursor 
6
CodeRank
This code example shows how to use the following methods:getRingtone, getRingtonePosition, setType
        final String s = settings.getRingtone();
        if ((s == null) || "".equals(s)) {
            return; 
        } 
 
        final RingtoneManager manager = new RingtoneManager(this);
        manager.setType(RingtoneManager.TYPE_ALL);
        ringtone = manager.getRingtone(manager.getRingtonePosition(Uri.parse(s)));
        if (ringtone == null) {
            return; 
        } 
 
        // TODO: AnnouncifySettings using ContentProvider 
        ringtone.setStreamType(new AnnouncifySettings(this).getStream());
        ringtone.play();
    } 
 
    protected void stopRingtone() { 
        if (ringtone != null) {
            ringtone.stop();
7
CodeRank
This code example shows how to use the following methods:getCursor, inferStreamType, setIncludeDrm, setType
6
CodeRank
This code example shows how to use the following methods:getRingtone, getRingtonePosition
			playRingtone(ringtone);
		} 
	} 
 
	private Ringtone getDefaultRingtone(Context context) {
		RingtoneManager ringtoneManager = new RingtoneManager(context);
		int position = ringtoneManager
				.getRingtonePosition(Settings.System.DEFAULT_RINGTONE_URI);
		Ringtone ringtone = ringtoneManager.getRingtone(position);
		return ringtone;
	} 
 
	private void playRingtone(Ringtone ringtone) {
		// TODO: Pull this time from settings. 
		int millis = 90000;
		try { 
			ringtone.wait(millis);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} 
5
CodeRank
This code example shows how to use the following methods:getCursor, inferStreamType, setIncludeDrm, setType
6
CodeRank
This code example shows how to use the following methods:getRingtoneUri, setType
	 
 
	public void soundPlay(int position){
		mMediaPlayer = new MediaPlayer();
		mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
		RingtoneManager mRingtoneManager = new RingtoneManager(this);
		mRingtoneManager.setType(RINGTON_STREAMTYPE);
		Uri uri = mRingtoneManager.getRingtoneUri(position);
		try { 
			mMediaPlayer.setDataSource(this, uri);
		} catch (IllegalArgumentException e) {
			// TODO 自動生成された catch ブロック 
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO 自動生成された catch ブロック 
			e.printStackTrace();
		} catch (IllegalStateException e) {
			// TODO 自動生成された catch ブロック 
			e.printStackTrace();
		} catch (IOException e) {
5
CodeRank

Related Android RingtoneManager Questions & Answers:

See Code Examples for Android RingtoneManager Methods: