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

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

Android ToneGenerator examples from Open Source projects
This code example shows how to use the following methods: release, startTone, stopTone, sleep
        ToneGenerator toneGen1;
        ToneGenerator toneGen2;
        int type;
        boolean result = true;
 
        toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
        toneGen2 = new ToneGenerator(AudioManager.STREAM_MUSIC, 50);
 
        if (toneGen1.startTone(ToneGenerator.TONE_DTMF_1)) {
            Thread.sleep(100);
            if (toneGen2.startTone(ToneGenerator.TONE_DTMF_2)) {
                Thread.sleep(500);
                toneGen1.stopTone();
                Thread.sleep(100);
                toneGen2.stopTone();
            } else { 
                toneGen1.stopTone();
                result = false;
            } 
        } else { 

8
CodeRank
This code example shows how to use the following methods: startTone
    if(am != null){
      if(am.getRingerMode() != AudioManager.RINGER_MODE_SILENT) {
        am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
      }else{ 
        am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, (int)(ToneGenerator.MAX_VOLUME * 0.85));
        if(tg != null){
          tg.startTone(ToneGenerator.TONE_PROP_BEEP);
        } 
      } 
    } 
    finish();
  } 
} 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: release, startTone, stopTone, sleep
        ToneGenerator toneGen1;
        ToneGenerator toneGen2;
        int type;
        boolean result = true;
 
        toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
        toneGen2 = new ToneGenerator(AudioManager.STREAM_MUSIC, 50);
 
        if (toneGen1.startTone(ToneGenerator.TONE_DTMF_1)) {
            Thread.sleep(100);
            if (toneGen2.startTone(ToneGenerator.TONE_DTMF_2)) {
                Thread.sleep(500);
                toneGen1.stopTone();
                Thread.sleep(100);
                toneGen2.stopTone();
            } else { 
                toneGen1.stopTone();
                result = false;
            } 
        } else { 

6
CodeRank
This code example shows how to use the following methods: startTone
        if(vib != null){
          vib.vibrate(50);
        } 
      }else{ 
        am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, (int)(ToneGenerator.MAX_VOLUME * 0.85));
        if(tg != null){
          tg.startTone(ToneGenerator.TONE_PROP_BEEP);
        } 
      } 
    } 
    finish();
  } 
} 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: stopTone
		} 
	} 
 
	public void stopDTMF() { 
		nowPlaying = null;
		generator.stopTone();
	} 
} 
Full Snippet Info
5
CodeRank
Related Android ToneGenerator Questions & Answers:
See Code Examples for Android ToneGenerator Methods: