Android Question Take a picture with the camera application

red30

Well-Known Member
Licensed User
Longtime User
When I click the button, I want to call up the standard camera application. Take a picture and display it. As in the video. How can i do this?
 
Last edited:

red30

Well-Known Member
Licensed User
Longtime User
I want to make a photo as in the example Camera intent. But i use two activities. I call the second activity and send the text to it:
B4X:
CallSubDelayed2(Second, "ShowList", "1_2")
Then i go to:
B4X:
Sub ShowList(Title As String)
    Name=Title
End Sub
After making a photo with Camera intent i go to:
B4X:
Sub Activity_Create(FirstTime As Boolean)
But
B4X:
Name=Title
is lost. How can I fix it?

B4X:
Sub Button2_1_Click
    Dim index As Int= CLV_Second.GetItemFromView(Sender)
    FotoInd=index
    TakePicture
End Sub
The idea is that I push the button and then call a standard camera app. I make a photo and staying in this activity. I want to save this photo to ImageView.Bitmap. Do you understand me? How can I do it?
 
Last edited:
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Store it in a process_global variable.
Thank you. And how can i push the button and then call a standard camera app. I make a photo and staying in this activity. I want to save this photo to ImageView.Bitmap. How can I do it?
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
I tried to do this:
B4X:
Sub Button1_Click
    OpenCam(File.DirDefaultexternal, "MyPicture.jpg")
End Sub
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
After I made the photo the program goes 2 times in Sub Activity_Create(FirstTime As Boolean). Can I make it so that the program after I made the photo moves only to Sub Activity_Resume?
 
Upvote 0
Top