I'm writing an app that uses the camera however I'm currently using the code:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivity(intent);
Which opens the camera but not the stock android camera app. Is there a way to do that? I want to use the stock camera so that I don't have to deal with saving photos/videos, or exception handling myself.
Related
I am integrating taking photo into my app using existing installed camera apps. On my phone, there are some camera apps installed, but I can only see the one that shipped with the phone.
Here is my code:
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
File tempFile = // ....
Uri photoURI = FileProvider.getUriForFile(getActivity(), "my_fileprovider", tempFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, RC_CAMERA_RETURN);
}
What I expected:
The app will show a list of installed camera apps and the user can pick up one.
My phone info: Sony Xperia Z2 with the following installed camera apps
Camera from Sony ( shipped with Z2) ----- Only see this one
Camera ZOOM FX
Retrica
I'm afraid that the target app you are referring to did not register itself appropriately as camera app.
If you know exactly what app you want to open, you might specify that information in an explicit Intent to open that particular app. Otherwise the user has to pick one of the available apps.
you can use to get app's manifest and get the Intent action and you can directly add action to the intent,
check App to check manifest of any app installed in android link here
That's How I solved same problem.
Is there a way to detect whether recording has started or not in android camera video?
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
Not for that Intent structure.
If you include EXTRA_OUTPUT, indicating where the video should be recorded, in theory you could watch to see when bytes are starting to get written to that file.
I'm working with some legacy code and the camera is opened using
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Which is fine. However, some code is running when the camera app is open (I'm not sure entirely why), but it does something if the camera app is in front of the user. The "top" app is retrieved, and then the code that checks if the camera is on top is:
boolean isCameraOnTop = topName.toLowerCase().indexOf("camera") != -1;
This was working fine for some time but we've been testing with a new device whose default camera app name is NOT "camera", but something else ("org.codeaurora.snapcam" if you must know). This approach seems flimsy as any device can have any default camera app.
SO, my question is, when I launch the camera app via the ACTION_IMAGE_CAPTURE intent, how can I find the app that actually gets opened?
After some searching, I found the solution:
activity.getPackageManager().resolveActivity(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY).activityInfo.packageName;
I have to attach voice recorded file as attachment to my android application. I have created a separate activity for voice recording without using inbuilt voice recorder application and it's working fine.
I thought of using the inbuilt application 'Voice Recorder' instead of using the activity which I have created.
I know that using Intent we should start the new activity. But I'm not able to find out how to start inbuilt voice recorder application and how it should be opened from my application?
Kindly let me know if anyone has experience in handling this scenario.
Thanks in advance!
You can try this
public static final int ACTIVITY_RECORD_SOUND = 0;
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, ACTIVITY_RECORD_SOUND);
I'm working on a app where I have to launch the camera. In Jelly Bean the gallery and camera merged and are now the same app (com.android.gallery3d I think). I've been searching for a answer on how to launch the camera but they're all about the startActivityForResult() method. I don't want the user to return to my app and I don't want my app to get the photo.
How can this be done?
This Intent works fine for me on JellyBean:
Intent intent = new Intent(android.provider.MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
startActivity(intent);