Android Question Error getting data back from camera app intent

red30

Well-Known Member
Licensed User
Longtime User
I took this example.
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#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.
    Dim cameraActivated As Boolean
    Dim camFileName As String
    Private lastPicture As Bitmap
    Private rp As RuntimePermissions
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 ImageView1 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Activity.LoadLayout("Layout1")
    Else
        Log("Нет разрешения(")
    End If
End Sub

Sub Activity_Resume
    If cameraActivated Then
        If File.Exists(File.DirRootExternal, camFileName) = True Then
            lastPicture.Initialize(File.DirRootExternal, camFileName)
            ImageView1.Initialize("")
            ImageView1.Bitmap=lastPicture
        End If
        cameraActivated = False
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    rp.CheckAndRequest(rp.PERMISSION_CAMERA)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Dim cam As EZcamera
    
        cameraActivated = True
        camFileName =  "test.jpg"
        cam.Initialize("Cam")
        cam.TakePicture(File.DirRootExternal, camFileName)
    Else
        Log("Нет разрешения(")
    End If
End Sub
On a Samsung tablet the program goes into Activity Create. And on other tablets it works fine.
Why is this happening?
In EZcamera Erel wrote:
The activity might be destroyed when your app is in the background. You can use StateManager module to preserve the UI state.
How can I do that? Give some example ...
 
Last edited:

red30

Well-Known Member
Licensed User
Longtime User
On a tablet (not a Samsung):
On the tablet Samsung:
On the tablet (not the Samsung), the program works fine. But on the Samsung tablet it switches to Activity_Create two times. I do not want it go there. How can I make the Samsung program work properly on the tablet? I do not want it go to Activity_Create.
 
Last edited:
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Samsung:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
** Activity (main) Create, isFirst = false **
running waiting messages (1)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
not a Samsung:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
Can I make the program (on the Samsung) not go into Activity Create?
 
Last edited:
Upvote 0
Top