I need to slightly modify the default camera intent in android - for example I want to start the camera in 360p quality, when starting front camera to be the active one and to be oriented in landscape. I have done a research and find some put extra options that could be used but it seems they do not work properly. So i think that the best way to do this is to find the build in camera intent code and do some modifications.
Where I can find the source of the build in camera intent and also the meta data part in the manifest(if there are some specific options to start the intent)?
I need to slightly modify the default camera intent in android - for example I want to start the camera in 360p quality, when starting front camera to be the active one and to be oriented in landscape.
I am going to guess that by "default camera intent" you mean an Intent for ACTION_IMAGE_CAPTURE.
I have done a research and find some put extra options that could be used but it seems they do not work properly.
For ACTION_IMAGE_CAPTURE, there is no extra to force 360p, and not all cameras support that resolution. There is no extra to force a front-facing camera, and not all devices have a front-facing camera. I am skeptical that EXTRA_SCREEN_ORIENTATION will do what you want, and there is no requirement that any camera app must support EXTRA_SCREEN_ORIENTATION.
So i think that the best way to do this is to find the build in camera intent code and do some modifications.
I am going to assume that by "build in camera intent code" you mean "built-in camera app".
Where I can find the source of the build in camera intent and also the meta data part in the manifest(if there are some specific options to start the intent)?
Few manufacturers ship the AOSP camera app. They replace it with their own. The source code for their own camera apps will be in their offices.
Related
I'm working on Android application that capture images and upload this images to a server.
I used intent to open the camera:
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
I need to open the camera in landscape orientation, I tried this approach and nothing changed
cameraIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
Any advice please.
The behavior of the camera app is up to the developers of the camera app. There are hundreds of camera apps, both pre-installed and user-installed. EXTRA_SCREEN_ORIENTATION is not documented as being part of the ACTION_IMAGE_CAPTURE protocol, and I am not aware of any camera apps that would honor it. There is no requirement for any camera app to let callers force a screen orientation.
You could integrate a camera library (CameraX from Google, etc.) and take photos yourself directly in your app. Then, you would be able to control the orientation of your screen (e.g., via android:screenOrientation in the manifest).
I want to develop camera functionality for my app where I have to capture 10 images. The camera should not close, rather it should continuously take pictures while I hold the shutter button. I am using intent for opening the camera, but after taking one image the camera is stopping. How can I achieve the desired functionality?
You would need to write your own camera code, using android.hardware.Camera and/or the android.hardware.camera2.* classes. There is no Intent structure that camera app developers are required to support that handles your use case.
My app crashes due to camera.putExtra("crop", "true"); Im assuming this is due to some stupid inconsistent vendor camera drivers or something... joys of fragmented market i guess.
How can i crop if this doesn't work? preferably have crop square on screen to guide user. Is there a standard ~99% proof method?
Give a look at the below mentioned link.
Android intent with multiple option i.e , Pick image from gallary and capture image using front camera
if you won't go to intent use crop library
https://github.com/jdamcd/android-crop
There is no crop intent in Android !!
From https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html
Many developers are calling startActivity() on an Intent with an action of com.android.camera.action.CROP. They are doing this to crop an image.
This is a really bad idea.
In this specific case, this Intent action is supported by the AOSP Camera app. That app does not exist on all devices. Devices lacking this app will not respond to this undocumented Intent action, and your app will crash.
Further reads: Explanation of Android Code Camera Intent + Croping Images
In essence, the above intent will crash on some devices.
I bet if commonsware's Author see this post , he could explain it even better.
Im assuming this is due to some stupid inconsistent vendor camera drivers or something... joys of fragmented market i guess.
Primarily, it is because that is not part of the Android SDK. There is no requirement for any camera app to support random Intent extras.
How can i crop if this doesn't work?
Use a library. Or write your own image cropping engine.
I am building an Android application where part of the functionality involves users taking images and recording video.
For the application there is a need to set a specific resolution for both the images and the video.
Is it possible to specify the resolution parameters and then use a camera intent to capture images and video or do I need to build my own camera activity?
Any advice would be greatly appreciated.
Edit: I did some additional research and had a look at http://developer.android.com/guide/topics/media/camera.html#intents.
If I understand correctly there is no option to specify resolution parameters when using the Image capture intent http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE.
For the Video capture intent it seems I have the option to use the Extra Video Quality parameter, however that only gives me the option of high quality and low quality (which I am not quite sure what corresponds to in terms of resolution) http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY
It seems I best get started developing my own image and video activities then, unless I missed some other options with the image and video intent.
Camera intent starts external camera applciation which MAY use your hints (but MIGHT NOT). The activity/application is non standard (phone vendor dependent), as well as the concrete implementation of the camera software.
You can also use the camera api ( working examples are in this project: http://sourceforge.net/projects/javaocr/ ) which allows you to:
query supported image formats and resolutions (you guessed it - vendor dependent)
set up preview and capure resolutions and formats (but camera software is free to ignore this setting, and some formats and resolutions can produce weird exceptions despite being advertised as supported)
Conclusion: cameras in android devices are different and the camera API is underdocumented mess. So be as defensive as possible.
Avoiding having to create a whole camera app myself, I am calling up:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
this.startActivityForResult(camera, PICTURE_RESULT);
However, the camera is very advanced and beautiful :) but not for my purposes. :(
Is there a way to restrict the camera to control size, resolution, disable setup button, flash, face recognition, etc...?
Sorry but you will be unable to change all these features using the Intents system. For this level of control you will have to create you own camera program.
http://developer.android.com/reference/android/hardware/Camera.html
You can change the autofocus and flash however using the uses tag in the manifest.xml