5

I need camera to appear in particular screen area in android here is the code that I use for camera activity

Now camera is working but it occupies whole screen I want camera to appear in particulat area of screen how to do this??

 private void uploadPhoto(String name) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File file = new File(Environment.getExternalStorageDirectory(), name
                + ".jpg");
        mImageCaptureUri = Uri.fromFile(file);
        try {
            intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                    mImageCaptureUri);
            intent.putExtra("return-data", true);
            startActivityForResult(intent, PICK_FROM_CAMERA);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
Sourabh Saldi
  • 3,567
  • 6
  • 34
  • 57

3 Answers3

3

You are opening the default camera app when you are using the camera intent. But if you need to display camera in a particular part of the screen you should consider making your own camera application. Read here for more http://developer.android.com/guide/topics/media/camera.html

Dinesh Venkata
  • 1,087
  • 1
  • 9
  • 22
3

In your code startActivityForResult(intent, PICK_FROM_CAMERA); starts an implicit intent and launches the camera application. Its a totally different application and hence it will occupy the whole screen by default. You cannot limit it to a particular part of the screen. If you require that you will need to create your own custom camera. There are many tutorials available for that. You can start here.

Community
  • 1
  • 1
Antrromet
  • 15,294
  • 10
  • 60
  • 75
3

You cannot use an intent for this. If you use an intent, it wil launch the camera app. Instead, you need to use something called a Camera Preview. This will show what the camera sees to the user and you can then use API's to control the camera actions.

here is a very nice tutorial for this from the official developer docs: https://developer.android.com/guide/topics/media/camera.html#custom-camera

Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84