0

I know there are many threads in relation to this topic as to how to customize the size of the window/frame of the camera (Is aspect ratio the correct term?) that shows preview of the image/environment before committing it (or clicking it) as an image.

I have tried this, this, this,this & especially another one from user Carlos, link for which I am unable to retrieve.

Thing is i just know the following lines of codes:

 camera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent cam = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cam, CAMERA_REQUEST);
        }

    });

  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_REQUEST) {
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        thumbView.setImageBitmap(photo);

         }
    }

That's it. I have tried typing from above links inside onCreate() but I have no clue.

Please guide from basics as to what will help me achieve a camera screen with a contracted square frame?

Community
  • 1
  • 1
Shridhar
  • 333
  • 1
  • 3
  • 15

1 Answers1

0

Unfortunately, you cannot control the camera screen with your approach.

You are launching the Camera Intent. This means that your app asks the system to perform the image capture for you, and the system will choose one of the registered apps that are willing to fulfill such task. More often than not, the system will launch the stock Camera app (the application that is preinstalled on the device), but a) different devices come with different preinstalled cameras and b) there are hundreds of custom camera apps on the Play Store.

There is no way to control this huge diversity of apps. There is only some hope that they will all respect the contract as defined on Android Developers page. But actually some of the apps ignore even these most basic requirements.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Sorry, got caught up with the project. Then as per your words there shouldn't be any app that has a customized camera preview frame? I think so there do exist, on Android market. If they do, then shouldn't it be possible to customize the frame size? – Shridhar Oct 19 '15 at 07:59
  • To have control over preview frame, and over virtually everything the camera does, you can implement "custom camera" instead of employing camera intent. There are many tutorials, even on Android developers official site. – Alex Cohn Oct 19 '15 at 18:54
  • If you ever come across a successful one with the code implemented, successfully, you may guide. That time I did encounter few but they were few which I couldn't find again and were kind of over my head at that experience level. – Shridhar Nov 24 '15 at 06:16
  • You can probably start with [this one](http://www.vogella.com/tutorials/AndroidCamera/article.html) – Alex Cohn Nov 24 '15 at 12:10