Hi to all !
I'm trying to implement a screen management within a phone app.
My target is to switch off the screen when the user put the phone near the ear and switch on when put off the phone from ear.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I'm running the code to handle the sensor but I it doesn't work as expected : the screen switch on / off isn't excuted.
Any Ideas?
			
			I'm trying to implement a screen management within a phone app.
My target is to switch off the screen when the user put the phone near the ear and switch on when put off the phone from ear.
			
				B4X:
			
		
		
		Sub Process Global
    Dim ps As PhoneSensors
End Sub
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
      ps.Initialize(ps.TYPE_PROXIMITY)
      ps.StartListening("ps")
    End If
End Sub
Sub ps_SensorChanged (Values() As Float)
   Log(Values(0))
   If Values(0)=0 Then 
        Log("Screen switch off")
        phoneWS.ReleaseKeepAlive
   Else 
        Log("Screen switch on")
        phoneWS.KeepAlive(True)
   End If
End SubI'm running the code to handle the sensor but I it doesn't work as expected : the screen switch on / off isn't excuted.
Any Ideas?
 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		