Android Question Native Camera Intent

MODERN TALKING

Active Member
Licensed User
Longtime User
Hi,

Wondering if anyone knows if it is possible to send Intent to the Native Camera to Auto-Snap Picture and then Exit

Thank you guys in advance
 

Indy

Active Member
Licensed User
Longtime User
Hi Erel

I'm sure being the expert that you are you are correct in saying that an "auto snap" would not be possible. However, my query then is, if I load an activity which in-turn launches a Camera intent, is it not possible that at some point in that Activity a timer could be used to take a picture? I haven't tried this but I do have an app where I launch an Activity with a full camera view where a user clicks a button to take and save a picture to the sd-card. Theoretically then, would it not be possible for me to click the button click event on a timer and then once the picture is saved, exit the activity? What you think?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
launches a Camera intent, is it not possible that at some point in that Activity a timer could be used to take a picture?
No. The camera intent starts a third party app. You don't have any control over that app.

You can implement it with Camera or Camera2 libraries.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
your request is similar a barcode reader app that just return the barcode and some other information, that works with zxing
because its part of design and i guess it is used from StartIntentWithResult
at my phone the camera app is from motorola and it seems this app not support it.
would be good if all app developer think about automation.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Using VBFrontcam library I do what you want (but without an intent). It can be done with any other camera library.
The application is started by a service which calls the camera activity, it saves the picture and calls another service to send the picture and then the application is shutdown.

B4X:
Sub Cam_Ready (Success As Boolean)
Try
    If Success Then
        cam.StartPreview
        cam.TakePicture
        Log("take picture")
    End If
Catch
    CallSub("runapp","send")
End Try
End Sub

Sub Cam_PictureTaken (Data() As Byte)
    Dim out As OutputStream
    out = File.OpenOutput(runapp.picdir, runapp.picfile, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
    cam.Release
    CallSub("runapp","send")
    CallSub(Main,"mainend")
'    Log("cam closed")
    Activity.Finish
End Sub
 
Last edited:
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Using VBFrontcam library I do what you want (but without an intent). It can be done with any other camera library.
The application is started by a service which calls the camera activity, it saves the picture and calls another service to send the picture and then the application is shutdown.

B4X:
Sub Cam_Ready (Success As Boolean)
Try
    If Success Then
        cam.StartPreview
        cam.TakePicture
        Log("take picture")
    End If
Catch
    CallSub("runapp","send")
End Try
End Sub

Sub Cam_PictureTaken (Data() As Byte)
    Dim out As OutputStream
    out = File.OpenOutput(runapp.picdir, runapp.picfile, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
    cam.Release
    CallSub("runapp","send")
    CallSub(Main,"mainend")
'    Log("cam closed")
    Activity.Finish
End Sub

Good job Derez, but is this for the Native BUILT-IN Camera or CameraEx, Camera2?
 
Last edited:
Upvote 0
Top