Code example for ToneGenerator

Methods: startTone

0
    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();
  } 
} 
Connect your IDE to all the code out there  Get Codota for Java