Android Tutorial [B4X] [B4XPages] Intent based camera

Status
Not open for further replies.
B4A + B4i project that uses an intent in B4A and the Camera object in B4i to take a picture using the default camera app.

The B4A code depends on JpegUtils: https://www.b4x.com/android/forum/threads/11629/#content
It rotates the bitmap based on the EXIF orientation attribute.

Don't miss:
- Manifest code in B4A.
- #PListExtra in main module in B4i.

B4i code was updated to fix an issue with the top page being removed from B4XPages stack.

The change adds a line before and after the Wait For Camera_Complete call:
B4X:
Dim TopPage As String = B4XPages.GetManager.GetTopPage.Id
Wait For Camera_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
B4XPages.GetManager.mStackOfPageIds.Add(TopPage) 'this is required as the page will be removed from the stack when the external camera page appears.
 

Attachments

  • CameraIntent.zip
    125.1 KB · Views: 302
Last edited:

Daniel44

Active Member
Licensed User
Excellent project Congratulations Erel!
Could you create an example but save the photos in a database or at least save the route of the photo taken? Thank you!
 

mangojack

Well-Known Member
Licensed User
Longtime User
The above example demonstrates taking a picture with the camera , saving it as a bitmap and setting it to ImageView. (see Button1_Click sub)

Here is some code to save that bitmap to Local SQL database and also retrieving it again (to Bitmap) .. There are many more examples available in the forum.

 

yzhy-mail

Member
Excellent project Congratulations Erel!
Could you create an example but save the photos in a database or at least save the route of the photo taken? Thank you!
I cann't agree with you more!
I learn the B4X deponding on example absolutly!
Example help me to understand the method qucikly.
if someone can give a example about "save and update the photos in a database and save the route of the photo taken"
that's so very kind of you !
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Project updated (B4A only):
- targetSdkVersion set to 33.
- A foreground service is started before the camera intent is sent. This prevents the OS from killing the app while it is in the background. Note that we don't need to request the new post_notifications permission for foreground notifications.
 
Status
Not open for further replies.
Top