sound Alert - Android User Interface

Android examples for User Interface:Alert Dialog

Description

sound Alert

Demo Code

import android.content.Context;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.os.Handler;

public class Main {
  public static void soundAlert(Context context) {

    final ToneGenerator toneGenerator = new ToneGenerator(
        AudioManager.STREAM_SYSTEM, ToneGenerator.MAX_VOLUME);
    toneGenerator.startTone(ToneGenerator.TONE_SUP_ERROR);// ??????
    Handler hundler = new Handler();
    hundler.postDelayed(new Runnable() {
      @Override//from  ww w  .ja va  2  s.  c  o m
      public void run() {
        toneGenerator.stopTone();
      }
    }, 1000);

  }
}

Related Tutorials