Sub mainpanel_click
Activity.LoadLayout("StalkScreen")
For LoopStopper = 1 To 1
camera1.Quality = C1Q
timer1.Initialize ("Timer1" , Speed)
timer1.Enabled = True
camera1.TakePicture
timer1.Enabled = True
Next
End Sub
First of all, I don't know why you are using a For...Next, second, you have a timer but do not have a Timer1_Tick routine.
It seems to me the camera part has a problem, if I comment the lines as shown below it seems to work, but you are not verifying if someone didn't select a file (tapping on the panel, then click on VIEW button and then the BACK button on the device) that also gives an error.
B4X:
Sub mainpanel_click
Activity.LoadLayout("StalkScreen")
'For LoopStopper = 1 To 1
'camera1.Quality = C1Q
timer1.Initialize ("Timer1" , Speed)
timer1.Enabled = True
'camera1.TakePicture
'timer1.Enabled = True
'Next
End Sub
...
Sub Timer1_Tick 'You don't have this routine in your code.
ToastMessageShow("Tick...", False)
End Sub
Ok thanks, but I want the app to take a photo, wait the specified time and keep on taking photos until the user stops the process. How should I go about this?
Also, I believe the problem lay specifically with the setting of the camera quality, what was I doing wrong their?
My sample uses the "official" camera library, what's the one you are using? but if you say you are having problems during TakePicture (NullException), reboot your phone, that should solve that problem.
I have rebooted a couple of times and it is still not working I have also removed the quality function so that I can use the standard camera library but the problem persists. I have been playing around a lot with the code but that still hasn't worked. Attached is as far as I have gotten.
Ok, by looking at your code I see a problem, if you want different layouts you have to either put them on different activities or use panels, that's the problem you are having.
Thanks NJDude, I have changed it so as that there are different activities. however, the problem persists. I am still getting Null pointer exception. Would anyone minded testing the app as it stands on their device just so I know that where the problem lies (code or device) and if its not to much effort suggest a possible solution for me to work on? Thanks
Well, it was failing because you forgot to add a few things, check the attached project and look at the "StalkScreen" activity, I made notes pointing out what you forgot.
Ok, by looking at your code I see a problem, if you want different layouts you have to either put them on different activities or use panels, that's the problem you are having.
Is it really necessary to use more than one activity or panels when using more than one layout? I've been using a Sub ('remove all views') each time just before loading a different layout. Is this not a good approach? Thanks.
It's better because it allows you maintain and debug your app more efficiently, at least, that's my opinion. In this case, there is a timer updating a view, by removing it, it causes the app to fail.
Sorry, I miss-phrased my question but I have the answer now: thanks for the help
In the sub chooser_result the code is as follows:
B4X:
Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
bmp.Initialize(File.DirDefaultExternal, FileName)
Else
ToastMessageShow("No image selected", True)
End If
End Sub
Then when I use 'bmp' the code is:
B4X:
Sub Activity_Create(FirstTime As Boolean)
PictureCounter = 0
If settings.bmp.IsInitialized Then
Camera1.Quality = settings.Q
Activity.LoadLayout("StalkScreen")
activity.SetBackgroundImage (settings.bmp)
stalkscreen.SetBackgroundImage (settings.bmp)
Camera1.Initialize(StalkScreen, "Camera1")
Timer1.Initialize ("Timer1", settings.timerinterval)
Timer1.Enabled = True
Else
Msgbox ("Please select an image" ,"")
StartActivity ("settings")
End If
End Sub
The image is not loading to the background though. Could you point me in the correct direction as to what to do.