Android Beep

less than 1 minute read

AndroidManifest.xml


MainActivity.java

    /**
     * Run beep tone
     */
    public void runBeepTone(int type) {

        if (!mCfgInfo.UseBeep) return;

        if (type == 0)
        {
            ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100); // volume level (STREAM_MUSIC)
            toneGen1.startTone(ToneGenerator.TONE_CDMA_PIP,150); // duration (TONE_CDMA_PIP)
            toneGen1.release();
        } else {
            ToneGenerator toneGen2 = new ToneGenerator(AudioManager.STREAM_MUSIC, 500); // volume level up
            toneGen2.startTone(ToneGenerator.TONE_CDMA_PIP,200); // duration up (TONE_CDMA_PIP)
            toneGen2.release();
        }
    }

Tags:

Categories:

Updated:

Leave a comment