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.
Related
I am just calling a camera intent like this:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, Constant.CAMERA);
Everything works fine, except when I start run this app for the first time.
I mean, if I wipe out data from my emulator, then start this app then,
The built-in Camera App shows some kind of first user tutorial if I start the camera intent.
After the tutorial, which is , even I take a picture, it does not show a confirmation check box. It keep stay as a built-in camera app and it does not return anything.
However, if I press back button and start the camera intent again, it works fine.
I am not sure how to prevent this kind of tutorial for the first time user.
I am not sure how to prevent this kind of tutorial for the first time user.
That is not possible. The decision of what a particular camera app will do in response to ACTION_IMAGE_CAPTURE is up to the developers of the camera app, not you or me.
Please bear in mind that ACTION_IMAGE_CAPTURE can wind up using any one of hundreds, if not thousands, of possible camera apps. The behavior of each of those camera apps will differ. And, since camera app developers do not seem to test ACTION_IMAGE_CAPTURE very much, you will get odd results like the one that you describe or various other things that you might consider to be a bug.
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
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.
In my app, I have to show the photos captured in a grid view and let user choose the one that they want to mess with. I am querying MediaStore.Images.Thumbnails to get the list of thumbnails to display.
The app works fine --well most of the time. However, when the user puts the app in the background and takes photo and launches the app again, it does not display the new photo. The reason is that I am not reloading the thumbnails onResume of my activity.
I do not want to refresh every time onResume because, most of the time it is unnecessary query to file system. My question is, is there a broadcast message or notification that I can register to get notified when a photo is taken from the camera even when my app is in background?
BTW: With still a lot of gingerbread phones around, the requirement is that it should work on 2.3.3 onwards.
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.