Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - SensorManager.getOrientation Not working on some devices

SensorManager.getOrientation Not working on some devices

Put your problem here if it does not fit any of the other categories.

SensorManager.getOrientation Not working on some devices

Postby Antonis123 » Wed Feb 15, 2012 12:26 pm

Hi,

I used SensorManager to get values :
orientationValues[0]: azimuth, rotation around the Z axis.
orientationValues[1]: pitch, rotation around the X axis.
orientationValues[2]: roll, rotation around the Y axis.

and put them to Text Views.
It seems to work on some devices i have tested it but not on Xperia Neo V and i hope you could tell me why and how can i make it work.
Code: Select all
public void onSensorChanged(SensorEvent sensorEvent) {
      
      if (sensorEvent.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE)
          return;

         // Gets the value of the sensor that has been changed
         switch (sensorEvent.sensor.getType()){ 
         case Sensor.TYPE_ACCELEROMETER:
          gravity = sensorEvent.values.clone();
          break;
         case Sensor.TYPE_MAGNETIC_FIELD:
          magnetic = sensorEvent.values.clone();
          break;
         }
         if (gravity != null && magnetic != null){

             // checks that the rotation matrix is found
             boolean success = SensorManager.getRotationMatrix(inR, I, gravity, magnetic);
             if (success){

              // Re-map coordinates so y-axis comes out of camera
              SensorManager.remapCoordinateSystem(inR, SensorManager.AXIS_X,
                SensorManager.AXIS_Z, outR);

              // Finds the Azimuth and Pitch angles of the y-axis with
              // magnetic north and the horizon respectively
              SensorManager.getOrientation(outR, orientVals);
              orientVals[0] = orientVals[0]*rad2deg;
              orientVals[1] = orientVals[1]*rad2deg;
              orientVals[2] = orientVals[2]*rad2deg;
              x.setText(Float.toString(orientVals[0]));
              y.setText(Float.toString(orientVals[1]));
              z.setText(Float.toString(orientVals[2]));
              

             
              
             }
            }   
      
      
   }


Sorry about my English
Thanks in advance
Antonis123
Freshman
Freshman
 
Posts: 2
Joined: Wed Feb 15, 2012 12:01 pm

Top

Re: SensorManager.getOrientation Not working on some devices

Postby Phyll » Wed Feb 15, 2012 12:56 pm

Hi Antonis123,

How does it not work? No values, wrong values, is the accelerometer available on that phone? Here is a tutorial on using the accelerometer that might help:

http://blog.androgames.net/85/android-a ... -tutorial/

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: SensorManager.getOrientation Not working on some devices

Postby Antonis123 » Wed Feb 15, 2012 1:35 pm

Phyll wrote:Hi Antonis123,

How does it not work? No values, wrong values, is the accelerometer available on that phone? Here is a tutorial on using the accelerometer that might help:

http://blog.androgames.net/85/android-a ... -tutorial/

Phyll


Thanks for the reply,
I get no values in this device. The accelerator and the magnetic field sensors work for this device(variables gravity and magnetic not null) but i cant get the orientation through SensorManager.getOrientation.
Antonis123
Freshman
Freshman
 
Posts: 2
Joined: Wed Feb 15, 2012 12:01 pm

Re: SensorManager.getOrientation Not working on some devices

Postby Phyll » Wed Feb 15, 2012 1:43 pm

Hi Antonis123,

Different manufacturers, different versions, even different carriers sometimes implement parts of the OS slightly differently. If you're sure you are not making a mistake in the way you are doing it then I guess I would suggest trying the listener and doing it yourself.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], MSNbot Media and 14 guests