Dear All
When the screen off , the senor seems to stop listening. How to make it listen while screen off.
Can anyone give me some suggestion? please.
Thanks very much in advance. My code is as following.
Main
=================================
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
StartServiceAt(svWakeup, DateTime.Now , True)
sensor.Initialize(sensor.TYPE_ACCELEROMETER)
End If
End Sub
Sub Activity_Resume
sensor.StartListening("sensor")
End Sub
Sub RestartSensor
sensor.StopListening
sensor.StartListening("sensor")
sensor.StartListening("sensor")
End Sub
Sub sensor_SensorChanged(Values() As Float)
Shake.HandleSensorEvent(Values)
End Sub
'---------------------------------------------------------------------------------------
svWakeup
==================================================
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
End Sub
Sub Service_Create
PE.InitializeWithPhoneState("PE", PhoneId)
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
End Sub
Sub PE_ScreenOff (Intent As Intent)
CallSub(Main,"RestartSensor")
End Sub
Sub PE_ScreenOn (Intent As Intent)
ToastMessageShow("Screen is ON",False)
End Sub
When the screen off , the senor seems to stop listening. How to make it listen while screen off.
Can anyone give me some suggestion? please.
Thanks very much in advance. My code is as following.
Main
=================================
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
StartServiceAt(svWakeup, DateTime.Now , True)
sensor.Initialize(sensor.TYPE_ACCELEROMETER)
End If
End Sub
Sub Activity_Resume
sensor.StartListening("sensor")
End Sub
Sub RestartSensor
sensor.StopListening
sensor.StartListening("sensor")
sensor.StartListening("sensor")
End Sub
Sub sensor_SensorChanged(Values() As Float)
Shake.HandleSensorEvent(Values)
End Sub
'---------------------------------------------------------------------------------------
svWakeup
==================================================
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
End Sub
Sub Service_Create
PE.InitializeWithPhoneState("PE", PhoneId)
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
End Sub
Sub PE_ScreenOff (Intent As Intent)
CallSub(Main,"RestartSensor")
End Sub
Sub PE_ScreenOn (Intent As Intent)
ToastMessageShow("Screen is ON",False)
End Sub