Device reboot with a service usage :-(

peacemaker

Expert
Licensed User
Longtime User
Hi, all

Who started to use SERVICES of v.1.2 ?
I'm beginning, mostly all is OK, but sometimes the emulator reboots while a service is running. The real device as well :-(.

Service now only uses GPS object and updates a notify icon text every second by a timer.
But reboot is not full - animated ANDROID text, like at booting is permanently on the display. Full restarting emulator or battery removing from the device is required for reset :(((.

Anyone meets such with services?
 

peacemaker

Expert
Licensed User
Longtime User
Erel, code has been emailed. Option "can install on ext. storage" is on.
Also found that after reboot the wallpaper setting is lost, maybe SD-card access problem ?
 

peacemaker

Expert
Licensed User
Longtime User
Any ideas, Erel ?
Service sometimes seems to make error and application is crashed even after start nothing changed more, just service's work.
An activity starts the service that inits GPS, TIMER, MEDIAPLAYER and some calculation subs, updating the notify ICON every second.

What might be wrong ? How to debug ?
 

peacemaker

Expert
Licensed User
Longtime User
No, every second is made icon's update:
Notif1.SetInfo("Text", IconText, Main)
Notif1.Notify(1)

But now no error more after TRY/CATCH (empty) in a timer_tick sub and in the audio sub:

Sub PlaySound (Dir,FileName)
Try
Do While mp.IsPlaying
DoEvents
Loop
mp.Load(Dir, FileName)
mp.Play
Catch
End Try
End Sub

That mostly plays OK as i need, one by one syncronously. Maybe this is a reason ...
 
Last edited:

agraham

Expert
Licensed User
Longtime User
B4X:
Try
Do While mp.IsPlaying
  DoEvents
Loop
This is a bad thing to do. I f you need to check periodically you should use a timer to let the CPU enter the OS idle loop and invoke its power saving measures. Running a loop burns CPU cycles and wastes battery power unnecessarily. In an event driven environment like Basic4andoid (and Basic4ppc) the only reason to use DoEvents should be to keep the UI alive while doing a long running computation. Running a loop using it is not a good thing.
 

peacemaker

Expert
Licensed User
Longtime User
Thanks, i see. But what can be a reason of error in service from such a sub ...
 
Top