the log in add_sensors is ok but if i move the phone don´t do anything
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim mp As MediaPlayer
Dim p As PhoneWakeState
Dim SensorsMapa As Map
Dim ps As PhoneSensors
Dim poss As Float
Dim poss2 As Float
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
SensorsMapa.Initialize
'This object is only used to access the type constants.
AddSensor(ps.TYPE_ORIENTATION, "ORIENTACION: ", True)
For i = 0 To SensorsMapa.Size - 1
ps = SensorsMapa.GetKeyAt(i)
Next
End Sub
Sub Service_Destroy
ExitApplication
End Sub
Sub sonido
If poss2=0 Then
Else If poss-poss2>10 OR poss-poss2<-10 Then
mp.Load(File.DirAssets,"grito.mp3")
mp.play
poss2=poss
End If
End Sub
Sub AddSensor(SensorType As Int, Name As String, ThreeValues As Boolean) As SensorData
Dim sd As SensorData
Dim ps As PhoneSensors
sd.Initialize
sd.Name = Name
sd.ThreeValues = ThreeValues
ps.Initialize(SensorType)
SensorsMapa.Put(ps, sd)
Log(Name & " MaxValue111111 = " & ps.MaxValue)
End Sub
Sub Sensor_SensorChanged (Values() As Float)
Dim pss As PhoneSensors
Dim sd As SensorData
ps = Sender
sd = SensorsMapa.Get(ps) 'Get the associated SensorData obejct
poss=NumberFormat(Values(0), 0, 3)
sonido
Return poss
End Sub