-1

This seems to be an old question, but I seriously need some help on this.

What I Want

I am having an activity where I want to show a small preview (or may not) of the user taking a picture of him/her using the front camera. When the user click a button, a snapshot would be taken ans stored in a location.

I want to support 4.0+ so I think I can use a TextureView.

But I really cannot add it to my layout or am getting any result. Please help me with a simple and easy solution so that I can get it working.

Thanks.

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107
  • Start with the camera demos that come with the Android SDK. Or if you have a specific issue with the front that you are encountering and it works on the back, show us where you are having issues. – Jay Snayder Mar 06 '15 at 20:29
  • @JaySnayder A step-by-step tutorial on this would be really helpful. – Aritra Roy Mar 06 '15 at 20:30
  • Are you receiving any type of error? If so, can you post it. Or perhaps some code of what you have already tried. – Coova Mar 06 '15 at 20:43

1 Answers1

0

Try https://github.com/alexcohn/JBcamera. Don't fall into the trap of using Camera.open(1) to address the front camera, use CameraInfo to check the mapping of number and facing.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Its truly awesome, I must say! But I specifically need the front camera to take pictures without a preview and if possible in a service. You you please update it, it will be a great help. – Aritra Roy Mar 09 '15 at 04:27
  • Hiding preview is a tricky task, not supported by Android platform, but it may work on your specific device. Some devices will simply allow **null** for preview display. Others will let you move the preview surface out of sight - e.g., to coordinates (-1000, -1000). On other devices you can set it to 1x1 pixel surface. You can also try to overlay the preview surface with some non-transparent view, but the preview surface has a tendency to pop up above others. – Alex Cohn Mar 09 '15 at 10:06
  • You can do everything in a service, but you still need a View, unless your device is satisfied with **null** for preview display. – Alex Cohn Mar 09 '15 at 10:10
  • Thanks for such an in-depth answer. But I see some popular apps like Vault or LockDown Pro doing this in all devices perfectly. There must be some way as they are doing it in all devices. At least, something, may not take the picture in non-supported devices but wont throw any exception. – Aritra Roy Mar 09 '15 at 15:04
  • I don't know a device that cannot take pictures without camera preview surface, but unfortunately it may sometimes be harder than expected. – Alex Cohn Mar 09 '15 at 22:25
  • 1
    I want to support my app o Android 4.0+, so using a TextureView is a solution as it supports being TRANSPARENT. So, can you please update your code with a TextureView. Thanks in advance. – Aritra Roy Mar 10 '15 at 13:09
  • You may find my other little program useful: https://github.com/alexcohn/OpenGLCamera. IIRC, it does not take snapshots, but it should be straightforward to add this functionality. – Alex Cohn Mar 10 '15 at 19:59
  • Thanks for that. Can the transparency be added to this? – Aritra Roy Mar 12 '15 at 13:37
  • You should check how transparent TextureView looks on your target device. – Alex Cohn Mar 12 '15 at 13:41