I have a very quick question about the camera. This is part of the code for a camera app I am making. The problem I am getting is that it will only take a maximum of 8 pictures and then simply stop. I am not sure whether it is my phone or if I am doing something wrong. Any thoughts?
Cheers,
Neil
P.S where it says home.picno that is referring to an 'int' in the home activity called 'picno' who's value is either 1000, 2000 or 5000
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim intervaltimer As Timer
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.
Dim NewImageView As ImageView
Dim Camera1 As Camera
Dim camerapanel As Panel
Dim al As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
home.lkjh = 0
intervaltimer.Initialize("Intervaltimer", home.iden)
If NewImageView.IsInitialized = True Then
If File.Exists(File.DirInternal, "screen.jpg") Then
NewImageView.Bitmap = LoadBitmap(File.DirInternal, "screen.jpg")
Else
NewImageView.Bitmap = LoadBitmap(File.DirAssets, "IMG_1814.png")
End If
NewImageView.Visible = True
Else
NewImageView.Initialize("NewImageView")
If File.Exists(File.DirInternal, "screen.jpg") Then
NewImageView.Bitmap = LoadBitmap(File.DirInternal, "screen.jpg")
Else
NewImageView.Bitmap = LoadBitmap(File.DirAssets, "IMG_1814.png")
End If
NewImageView.Gravity = Gravity.FILL
Activity.AddView(NewImageView, 0 ,0, 100%x, 100%y)
End If
camerapanel.Initialize("camerapanel")
Activity.AddView(camerapanel, 99.4%x , 99.4%y, 100, 100)
al = 1
' If home.flash = True Then
' If Camera1.isLEDEnabled Then
' Camera1.
' Else
' Camera1.FlashOff()
' End If
End Sub
Sub Activity_Resume
Camera1.Initialize(camerapanel, "Camera1")
' If home.flash = True Then
' Camera1.FlashOn
' Else
' Camera1.FlashOff
' End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Camera1.Release
End Sub
Sub Camera1_Ready (Success As Boolean)
If al = 1 Then
Camera1.StartPreview
If Success = True Then
home.ready = True
intervaltimer.Interval = home.iden
intervaltimer.Enabled = True
Else
home.ready = False
End If
Else
End If
End Sub
Sub NewImageview_click
Dim result As Int
result = Msgbox2("You have stopped stalking. Tap Close to restart or tap View to see the Stalker Roll", "Stalker", "View", "", "Close", Null)
If result = DialogResponse.POSITIVE Then
NewImageView.Visible = False
intervaltimer.Enabled = False
StartActivity("home")
Else If result = DialogResponse.NEGATIVE Then
End If
End Sub
Sub intervaltimer_tick
If home.ready = False Then
Else
Camera1.TakePicture
End If
End Sub
Sub Camera1_PictureTaken (Data() As Byte)
Dim out As OutputStream
out = File.OpenOutput(File.DirInternal, home.picno & ".jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
File.Delete(File.DirInternal, "Number.txt")
Dim TextWriter1 As TextWriter
TextWriter1.Initialize(File.OpenOutput(File.DirInternal, "Number.txt", False))
Dim listuno As List
listuno.Initialize
listuno.Add(home.picno + 1)
listuno.Add(home.picno + 1)
listuno.Add(home.picno + 1)
TextWriter1.WriteList(listuno)
TextWriter1.Close
Dim listun As List
listun = File.ReadList (File.DirInternal, "Number.txt")
home.picno = listun.Get(1)
End Sub
Cheers,
Neil
P.S where it says home.picno that is referring to an 'int' in the home activity called 'picno' who's value is either 1000, 2000 or 5000