Android Question app DOES NOT RESPOND dialogue

peacemaker

Expert
Licensed User
Longtime User
I have found that recent months my apps (mostly using HttpUtils2) after start in several seconds are followed by the "app does not respond" system dialog.
In long FOR loops i always use the code like
B4X:
If (i mod 100) = 0 then DoEvents
B4A is always latest actual (now v.4.3), but test devices are the same recent years (see my signature).

But now in app template with the service working with the accelerometer, without loops and DoEvents it has occured also :-(

Erel, full source code is emailed to you.
Any help ?

Team, did you have such issue recent 2-3 years (at least with apps using HttpUtils2) ?
 

DonManfred

Expert
Licensed User
Longtime User
Using DoEvents is not a solution.
The solution will be using Threads and/or Async tasks for longer loops. Maybe a service.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
This time the service has only
B4X:
Sub Service_Create
others.Notif("Started OK.", False, False, Main, "")
Service.StartForeground(8, Notif1)

Try
    sensor.Initialize(sensor.TYPE_ACCELEROMETER)
    AccelExists = True
Catch
    AccelExists = False
    ToastMessageShow("No accel: stopped", True)
    CallSub(Main, "Activity_Close")
    StopService(Me)
End Try
End Sub

Private Sub Sensor_SensorChanged (Values() As Float)
SensorX1 = Round(Values(0)) * 10
SensorY1 = Round(Values(1)) * 10
SensorZ1 = Round(Values(2)) * 10
End Sub

sensor.StartListening("Sensor") is used separately, by an interface button
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Clear, but this app with accelerometer without HttpUtils2 ? (i emailed the full source)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Indeed - DoEvents was the issue...
Solved.
Do not use DoEvents at service start.

But how to be sure correctly that a service is started, all initialized, database is opened.... before letting the user to work with the activity ?
In big app it's needed long time for whole initializations.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, from activity, but activity interface depends on the service work, that should be inited first, for rather long time.
Thanks for suggestion.
 
Upvote 0
Top