Is it possible to receive an intent each time the user take a picture with the device camera?
No, sorry. You can use a FileObserver to monitor the standard photo directory on the device, but that assumes that the app that the user is using is storing photos there.
Related
I'm developing an app that reads the metadata of images from a device.
One of the conditions is to have activated the geolocation for the photos of your camera to retrieve latitude/longitude from images.
Is it possible to send user (via Intent or something else) to the Camera settings/preferences directly?
I know it's possible to send user to general settings
Intent intent = new Intent(Settings.ACTION_SETTINGS);
startActivity(intent);
But I'm looking for a way to send it directly to the camera settings.
Is it possible to send user (via Intent or something else) to the Camera settings/preferences directly?
No.
I mean the "standard" Camera application of the device. In system settings usually exists a list of your apps and one of them is the Camera application.
No. There are ~2 billion Android devices, comprising thousands of device models. Those ship with hundreds of pre-installed camera apps, let alone the additional camera apps that users might install.
And, of note:
None of those camera apps have to have any sort of settings/preferences screen
None of those camera apps have to offer geolocation
I have a requirement to develop an application which will monitor the usage of the phone cameras and record information about when/where a photo was taken. I am aware that this information is typically recorded in the image metadata but I have a need to add additional information to this and record it separately from the image.
In essence, I would like to know:
Any time the camera is opened, closed, activated (brought to front), deactivated (user switches to another app)
Any time the camera saes a file; either a photo or a video
Know the above regardless of whether the camera was launched directly or via another app
Know the above regardless of whether the caller used an intent or the camera APIs.
Are there good APIs to use for this? Is it possible to replace low-level interfaces to act as a man-in-the-middle? Is it possible from Java or would this necessarily be in C/C++?
At the moment my only solution would be to monitor the logs in a continuous service to identify everything I could from the above and implement a FileObserver to check for file creation/modification times.
Are there good APIs to use for this?
There are no APIs for this, for obvious privacy and security reasons.
Is it possible to replace low-level interfaces to act as a man-in-the-middle?
On a rooted device, perhaps. In a custom ROM, definitely. In an ordinary Android device, no, for obvious privacy and security reasons.
would be to monitor the logs in a continuous service to identify everything I could from the above
You have no access to logs, other than those generated by your own process, on Android 4.1+, except on rooted devices or from a custom ROM.
and implement a FileObserver to check for file creation/modification times
There is no requirement for a camera app to store a file in a place for which you have filesystem access.
Per the Google Android camera tutorial I'm using:
new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
or
new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
to open the camera in my app.
Unfortunately, this forces the user to decide beforehand and prevents the user from toggling between pic & vid modes.
My problem is I want the user to go directly to the camera, be able to toggle between picture & video mode,
and then save the image/video accordingly.
Is there some way to:
1) read the Intent data in onActivityResult() and
2) ascertain (AFTER the image has been saved, NOT before) whether it's a pic or a video,
then
3) rename the image to ".jpg" or ".mp4" accordingly?
I've noticed that when I use
new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
that the camera can then toggle between pic & vid.
But then it won't programmatically save the file.
I want the user to go directly to the camera, be able to toggle between picture & video mode, and then save the image/video accordingly.
That is not going to be possible in general, for the simple reason that you are asking other apps to take pictures and videos on your behalf. The protocol that Android has established for doing that is via the Intent actions that you are presently using. There is no ACTION_CAPTURE_SOMETHING_THAT_THE_USER_THINKS_IS_COOL or the equivalent that allows you to express that you want the user to make a choice after starting the third-party camera activity.
I've noticed that when I use new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA);
that the camera can then toggle between pic & vid.
Only for the couple of camera apps that you have tried, out of thousands (pre-installed by device manufacturers, downloaded by users from the Play Store, etc.). The documentation certainly would not imply that behavior would be expected of all camera apps.
I want to write application on Android that starts in background when user launches a built-in camera (it is important: build-in camera, not an application) and do some actions after user makes a photo.
Is it real? If yes, how to implement this?
I doubt if this is possible. There is no mechanism which android provides that causes a broadcast to the system that Camera has been launched. Plus, you cannot modify the contents shown on the screen as the Camera application is in command. The only way out is to have a MediaScanner and FileObserver to check when a new picture is created in DCIM/Camera/ folder and make your app act accordingly
A User takes pictures using camera in his device. My application should keep track of how many photos captured by the user.
I don't want my application to launch any default camera. I want to get count incremented for clicked photos by the user with his device camera.
Since devices having soft button camera not works with CAMERA_BUTTON intent, so is there any other way to get count.
my application should keep track of how many photos captured by the user
In general, that is impossible. You have no ability to spy on arbitrary actions of other applications.
The closest thing is what julian suggested -- use a FileObserver to monitor Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM). However, not all camera applications will store their pictures there.