Error with PhoneSensors

Hello,
I am a newbie here and I have a problem with reading orientation sensor.
I have created a program (see code below) whose aim is to show data from Orientation sensor in label named "data". I tried it many times (it did not work) until without any reason (I changed nothing) compiler started to show me an error:

Parsing code.
Error parsing program.
Error description: Unknown type: phonesensors;
Are you missing a library reference?
Occurred on line: 44
Dim ps As PhoneSensors;

Here is my code:
B4X:
Sub Process_Globals
   Dim speed As Int
   Dim ballx, bally As Float
   Dim time As Timer
End Sub

Sub Globals
   Dim can As Canvas
   Dim Greitis As EditText
   Dim OK As Button
   Dim Start As Button
   Dim Stop As Button 
   Dim Vaizdas As ImageView
   Dim velocity As String
   Dim Data As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      Dim ps As PhoneSensors
       Activity.LoadLayout("labyrinth")
       can.Initialize(Vaizdas)
       time.Initialize("Timer1",10)   
      ps.Initialize(ps.TYPE_ORIENTATION)
   End If
   time.Enabled = True
End Sub
   
Sub Activity_Resume
       Dim ps As PhoneSensors
      ps.StartListening ("Orientation")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
        Dim ps As PhoneSensors;
      ps.StopListening
End Sub

Sub Sensor_SensorChanged (Values() As Float)
        Log ("Label_text")
       Data.Text = " X=" & NumberFormat(Values(0), 0, 3) & ", Y=" & NumberFormat(Values(1), 0, 3) _ 
      & ", Z=" & NumberFormat(Values(2), 0, 3)
End Sub      

Sub Timer1_Tick

End Sub
Sub trig (x As Int, y As Int)
End Sub
Sub Stop_Click
     Dim ps As PhoneSensors
    ps.StopListening
    time.Enabled = False   
End Sub
Sub Start_Click
     Dim ps As PhoneSensors
    ps.StartListening ("Orientation")
    time.Enabled = True      
End Sub

Sub OK_Click
speed = velocity
End Sub
Sub Greitis_TextChanged (Old As String, New As String)
velocity = New
End Sub
Sub Cartesian_to_Polar (x As Int, y As Int)
End Sub
Sub Polar_to_Cartesian (kampas As Float, r As Float)
End Sub

Do not mind empty subs, there are going to be my next parts of program.

Please help me to solve this situation.

Regards,
Rokas
 

eps

Expert
Licensed User
Longtime User
"Are you missing a library reference?"

Check the Libs tab.. are you missing a library reference?

Is the manifest set to read only?
 
Upvote 0
After some relax I found that I did a tiny error:
Dim ps As PhoneSensors;
It is not necessary sign ;
Ehh, influence of C language :)
But the program still does not show values of orientation sensor
 
Upvote 0
Thanks, Erel, but I have read it. I did my program with this example and really in my program there is only one big difference. In your example you add a label with AddView command, but I add the label with the Designer. That is why I do different program.
 
Upvote 0
Top