Hi!
I can't make accelerometer start/stop working in my live wallpaper when user enables/disables it in preferences menu. The code I used:
accelerometer works all the time and changing accel has no affect.
First I used another code for long time, but result was similar. I also mentioned that accelerometer does not turn off when service is destroyed because of fast battery draining. This is the code I was using before:
Guys help me please, I tried everything I could but nothing help, I stuck on this for long time.
I can't make accelerometer start/stop working in my live wallpaper when user enables/disables it in preferences menu. The code I used:
B4X:
Sub Process_Globals
Dim ps As PhoneSensors
end sub
Sub Service_Create
If accel=True Then'accel=True enables accelerometer, false disables
ps.Initialize(ps.TYPE_ACCELEROMETER)
ps.StartListening("Sensor")
Else
ps.StopListening'I added this after, hoping it will help, but it didn't
End If
end sub
Sub servise_destroy
ps.StopListening
End Sub
Sub Sensor_SensorChanged (Values() As Float)
accx=Values(0)'global variables
accy=Values(1)
end sub
First I used another code for long time, but result was similar. I also mentioned that accelerometer does not turn off when service is destroyed because of fast battery draining. This is the code I was using before:
B4X:
Sub Process_Globals
Dim Accelerometer As PhoneAccelerometer
end sub
Sub Service_Create
If accel=True Then'accel=True enables accelerometer, false disables
Accelerometer.StartListening("Accelerometer")
End If
end sub
Sub servise_destroy
Accelerometer.StopListening
end sub
Sub Accelerometer_AccelerometerChanged (Xx As Float, Yy As Float, Zz As Float)
accx=Xx
accy=Yy
end if
Guys help me please, I tried everything I could but nothing help, I stuck on this for long time.