How to make a camera in a specific area of ​​the screen in Android?

I need the camera to display in a specific area of ​​the screen in Android, here is the code that I use for the camera’s activity

Now the camera works, but it occupies the entire screen. I want the camera to appear in part of the screen screen, how to do it.

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(); } } 
+4
source share
3 answers

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

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

+3
source

You open the default camera app when you use the camera intent. But if you need to display the camera in a specific part of the screen, you should consider creating your own camera application. Read more here http://developer.android.com/guide/topics/media/camera.html

+3
source

In your code, startActivityForResult(intent, PICK_FROM_CAMERA); an implicit intention is triggered and the camera application is launched. This is a completely different application, and therefore it will occupy the entire screen by default. You cannot limit it to a specific part of the screen. If you need to, you need to create your own camera. Many training programs are available for this. You can start here .

+3
source

Source: https://habr.com/ru/post/1437730/


All Articles