Nexus 7 Camera

joneden

Active Member
Licensed User
Longtime User
Hi All,

So has anyone had any success at all with using the Nexus 7 front camera.

I've tried using the ACL lib and the vbFrontCamera lib but neither work on the Nexus 7 :(

Thanks for any help.

Regards,

Jon
 

NJDude

Expert
Licensed User
Longtime User
You could try this code to do that:
B4X:
Sub OpenCam(Directory As String, PictureName As String)

    Dim i As Intent

    i.Initialize("android.media.action.IMAGE_CAPTURE", "")
    i.PutExtra("output", ParseUri("file://" & File.Combine(Directory, PictureName)))
            
    StartActivity(i)
            
End Sub

Sub ParseUri(FileName As String) As Object

    Dim r As Reflector

    Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(FileName), Array As String("java.lang.String"))

End Sub
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Looks promising but when I tried it, it just stopped at the save bit with the cross and tick.

Is there a way to get the data back into the app as a byte array? Also not having done much at all with intents, how does the app receive control back ?

I feel like a big time newbie on this one!

Regards,

Jon
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
That code is actually saving the picture to the folder you indicate, just open the picture.

For example:
B4X:
OpenCam(File.DirDefaultExternal, "MyPicture.jpg")

You snap the picture using the devices camera app and saves the picture to File.DirDefaultExternal.
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
That's great! I realised that the resume activity will be raised once back in my app so I just use the pic then delete it once done...

Fantastic - many thanks for your help!

Regards,

Jon
 
Upvote 0
Top