I took this example.
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:
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
Why is this happening?
In EZcamera Erel wrote:
How can I do that? Give some example ...The activity might be destroyed when your app is in the background. You can use StateManager module to preserve the UI state.
Last edited: