简体   繁体   English

在Android设备中禁用相机的快门声

[英]Disable shutter sound of camera in android device

I have written a simple application in which the user can: 我编写了一个简单的应用程序,用户可以在其中进行以下操作:

  • press a button to open the camera application 按下按钮以打开相机应用程序
  • take pictures with the camera application 使用相机应用程序拍照

Is there any way to disable the shutter sound of the camera from my code? 有什么方法可以从我的代码中禁用相机的快门声吗? I currently hold an Orange Nivo phone with Android 4.1.2 version on it. 我目前持有装有Android 4.1.2版本的Orange Nivo手机。

A secion of my code is: 我的代码的一部分是:

          public void onClick(View v) {
                try {
                    f = createImageFile();
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
                    startActivityForResult(cameraIntent, CAMERA_REQUEST);   
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }



            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  

            Bitmap photo = BitmapFactory.decodeFile(f.getAbsolutePath());
            Bitmap newphoto = Bitmap.createScaledBitmap(photo, 200, 200, false);     
            imageView.setImageBitmap(newphoto);

I would appreciate any suggestions on how to achieve this effect. 我将不胜感激有关如何实现此效果的任何建议。 I know that there are applications on Android store that take pictures without the shutter sound, so i suppose there must be a way to do this without rooting the phone. 我知道Android商店中有一些应用程序可以在没有快门声的情况下拍照,所以我想必须有一种无需扎根手机的方法。

The simple answer is: you can not! 简单的答案是:您不能!

The reason is that it is against the law to take a picture without the shutter making sound, this is for privacy concerns. 原因是在没有快门发出声音的情况下拍照是违法的,这是出于隐私方面的考虑。 Moreover, as you will notice, you can't take a picture even when your camera preview is not set properly, still for privacy reasons. 此外,您会注意到,即使出于隐私原因,即使相机预览设置不正确,也无法拍照。 At this point you have four options: 此时,您有四个选择:

  • Find a way to hack the API 找到一种破解API的方法

  • Root the phone and disable the shutter sound 拨入手机并禁用快门音

  • Write your own native code for the camera...but this may be highly dependant on the device you're using it 为相机编写自己的本机代码...但这可能在很大程度上取决于您所使用的设备

  • Use the siplest way that is also the way used by most (if not all) the silent camera 使用最简单的方法,这也是大多数(如果不是全部)无声摄像机使用的方法

applications in the market. 市场上的应用。 Simply intercept the preview frame via the onPreviewFrame callback from your onClickListener and then save it as an image. 只需从onClickListener的onPreviewFrame回调中截取预览帧,然后将其另存为图像即可。 The major drawback here is that the maximum preview resolution is far less than the maximum picture resolution so the photo you will take this way will have a fairly low resolution. 这里的主要缺点是最大预览分辨率远远小于最大图片分辨率,因此您将以这种方式拍摄的照片将具有较低的分辨率。 Indeed if you read the comments on the silent camera apps on the market you will see a lot of people complaining about the resolution of the images not being so high. 确实,如果您阅读了市场上有关无声相机应用程序的评论,您会发现很多人抱怨图像的分辨率不是很高。 This is the reason why: they use the trick I exaplained you above. 这就是原因:他们使用了我在上面为您夸奖的技巧。

To conclude, there is no easy way to achieve what you want! 总之,没有简单的方法可以实现您想要的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM