Android Question Service when a person puts their hand over the screen

mangojack

Expert
Licensed User
Longtime User
Are you asking .. Can I Run / Start a Service when the proximity sensor is activated. ??
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I want a service that when a certain app is running it starts looking for a person to put their hand over the screen. If it can be done then how.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Still unsure of what your trying to do , but this might be of some help.

* Check inclusion of Phone lib ...
B4X:
Sub Process_Globals
    Dim ps As PhoneSensors
End Sub

Sub Globals

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("Player has hand over phone ..")
    Else
        Log("Player has removed hand  ..")
    End If
End Sub

Make sure to call ... ps.StopListening somewhere in your app when finished.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…