Reputation: 33
I have problem with my app and i have no idea where is the cause. I am developing an application, which connect with PC by Wi-Fi, and shows on phone screen orientation. All about sending works perfectly, but part with orientation sensor not. The strange fact is when i do app only with sensor part it works. Maybe threads something changes.
in on create
txtView = (TextView) findViewById(R.id.txtView);
txtView2 = (TextView) findViewById(R.id.txtView2);
txtView3 = (TextView) findViewById(R.id.txtView3);
SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor mOrientation = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
in on sensor change
@Override
public void onSensorChanged(SensorEvent event) {
azimuth_angle = event.values[0];
pitch_angle = event.values[1];
roll_angle = event.values[2];
txtView.setText(azimuth_angle+" ");
txtView2.setText(pitch_angle+" ");
txtView3.setText(roll_angle+" ");
Log.e("kacper", azimuth_angle+" "+pitch_angle+" "+roll_angle);
i checked that onSensorChanged is no called. why its not working when in new empty activity works good and refresh very often.
Upvotes: 2
Views: 701
Reputation: 99
have you register the listener?
mSensormanager.registerListener(this, mOrientation ,
SensorManager.SENSOR_DELAY_FASTEST);
Upvotes: 1