1

I'm using a standard MediaStore.ACTION_VIDEO_CAPTURE Intent call (e.g. the one on the Developer site or lots of StackOverflow threads) to record some video. I'm testing it on a (real) Nexus 7 (API 21) and it works fine...so long as the device's display is in a landscape orientation when the (native) Android camera app starts up. If it is portrait, reverse-portrait or reverse-landscape, the camera app stops part way through its initialization ("Unfortunately, Camera has stopped") and control returns to my app. The camera app is happy to reorient to portrait once it has initialized in landscape, however. And if I use MediaStore.ACTION_IMAGE_CAPTURE, it'll start in portrait or landscape.

I know that I can fix the orientation of my app to landscape and I know that I can request the camera to record in landscape, but if the user happens to be holding the device in portrait anyway, the screen rotates to vertical during the transition, as my app releases control to the camera app. The camera app then receives control while the orientation is portrait and it doesn't like it and stops. The issue is not due to a change of orientation -- even if I keep everything locked to portrait throughout, the camera app cancels part-way through its initialization routine.

Is there a way to avoid this happening (while still using the camera via Intent)?

(PS I notice from here, about bespoke camera routines: "Note: A camera preview does not have to be in landscape mode..." and goes on to explain how to make that happen. Does that mean that the "Intent" implementation does?)

  • Camera preview does not have to be in landscape mode (and that's what you see with ACTION_IMAGE_CAPTURE), but unfortunately video capture often does. You are lucky to experience this behavior on your device, and not on some end-user devices that you cannot get hold of. – Alex Cohn Mar 26 '15 at 14:37
  • The best strategy is to create a back list of devices (device models) that require landscape orientation to capture video. If you identify such behavior on *Othersung Constellation 5S" device, simply add it to the list, and then all other users with same device will be seamlessly shifted to landscape before the intent is launched. – Alex Cohn Mar 26 '15 at 14:43
  • "users with same device will be seamlessly shifted to landscape before the intent is launched" -- the thing is, putting the device in landscape before the intent doesn't guard against them choosing to hold it in portrait despite what the screen shows...and as soon as my app passes on control to the camera, the screen goes back to being portrait and triggers the crash. :( – Stuart Billington Mar 26 '15 at 14:53
  • well, their smooth experience means that you will work hard to prepare it, and your server will be up to the task – Alex Cohn Mar 26 '15 at 14:57
  • I have a couple of workarounds for you. Maybe, you can launch the ACTION_IMAGE_CAPTURE intent and few milliseconds later - the ACTION_VIDEO_CAPTURE intent. – Alex Cohn Mar 26 '15 at 15:22

1 Answers1

1

Is there a way to avoid this happening (while still using the camera via Intent)?

No.

More specifically, there are thousands of possible camera apps -- preloaded or installed by users -- that could claim to support ACTION_VIDEO_CAPTURE, and any of them can have bugs as this one does. There is no EXTRA_PLEASE_AVOID_BUGS that you can pass on the Intent to change that (though that'd be really cool...).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    That is deeply frustrating...such a simple thing! Thank you for letting me know. – Stuart Billington Mar 26 '15 at 14:51
  • Unfortunately, different ROMs provide the "custom camera API" which can also not be 100% compliant or consistent with the official API. Even on Nexus devices. – Alex Cohn Mar 26 '15 at 15:37