B4A Library MagicalCamera

For some reason this Github project is called Magical Camera. I have done a very basic "shortcut" wrapper to kick start this from B4A. Amend the Java code (posted) to your liking.

Posting the following:
1. B4A project
2. Java Code - extract the java code and create a libs folder on the same folder level as the src folder. Then copy android-support-v4.jar and android-support-v7-appcompat.jar into the libs folder before compiling the Java code. I guess everyone should already have these 2 jars in their additional library folder.
3. The B4A library files - copy them to your additional library folder.

1.png


2.png



3.png


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: MagicalCamera
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource

'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Private Label1 As Label
    Dim mycam As MagicalCamera

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

    Activity.LoadLayout("main")
    mycam.Initialize("")
    Label1.Visible = True
    Label1.Text = "Wrapped by Johan Schoeman"

End Sub

Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

  mycam.StartCamera

End Sub

Library:
MagicalCamera
Author:
Github: Fabian Rosales-Frosquivel , Wrapped by: Johan Schoeman
Version: 1
  • MagicalCamera
    Methods:
    • Initialize (paramString As String)
    • IsInitialized As Boolean
    • StartCamera
    Permissions:
    • android.permission.CAMERA
    • android.permission.READ_EXTERNAL_STORAGE
    • android.permission.WRITE_EXTERNAL_STORAGE


Take note of the B4A project's manifest file (the activities). All required permissions are automatically added by the wrapper.

If you SAVE the photos after taking a snapshot the photos will be stored in the /pictures/MAGICAL_CAMERA folder of your device (starting from your device's root folder).
 

Attachments

  • b4aMagicalCamera.zip
    196.7 KB · Views: 270
  • MagicalCameraLibFiles.zip
    14.8 KB · Views: 271
  • TheJavaCode.zip
    9.2 KB · Views: 256
Last edited:

tuhatinhvn

Active Member
Licensed User
Longtime User
thank you for your code, can you update ver 2.0 to get string image captured and not show form to select file??
 
Top