Get Camera click sound - Android android.hardware

Android examples for android.hardware:Camera

Description

Get Camera click sound

Demo Code

import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;

public class Main {

  public static void shootSound(Context context) {
    AudioManager meng = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    int volume = meng.getStreamVolume(AudioManager.STREAM_NOTIFICATION);

    MediaPlayer _shootMP = null;/*from  w w  w .j  a  v  a  2  s.c o  m*/

    if (volume != 0) {
      if (_shootMP == null)
        _shootMP = MediaPlayer.create(context.getApplicationContext(),
            Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));
      if (_shootMP != null)
        _shootMP.start();
    }
  }

}

Related Tutorials