Android didUpdateHeading (fate manager)?

Does Android have the equivalent of didUpdateHeading (from iOS)? Any sample code to rotate an image using it?

I searched a lot, but could not get a useful hint.

Thanks in advance.

Edit: Let me tell you about my question: on iOS, when the device changes the title, the delegate object gets called by its method: "didUpdateHeading". In Android, I could find "onLocationChanged" to get the coordinates, but not the title. How to get header information in Android?

+4
source share
2 answers
package com.exercise.AndroidCompass; import java.util.List; import android.app.Activity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.Toast; public class AndroidCompass extends Activity { private static SensorManager mySensorManager; private boolean sersorrunning; private MyCompassView myCompassView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myCompassView = (MyCompassView)findViewById(R.id.mycompassview); mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); List<Sensor> mySensors = mySensorManager.getSensorList(Sensor.TYPE_ORIENTATION); if(mySensors.size() > 0){ mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), SensorManager.SENSOR_DELAY_NORMAL); sersorrunning = true; Toast.makeText(this, "Start ORIENTATION Sensor", Toast.LENGTH_LONG).show(); } else{ Toast.makeText(this, "No ORIENTATION Sensor", Toast.LENGTH_LONG).show(); sersorrunning = false; finish(); } } private SensorEventListener mySensorEventListener = new SensorEventListener(){ @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { // TODO Auto-generated method stub } @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub myCompassView.updateDirection((float)event.values[0]); } }; 

Source: http://android-er.blogspot.com/2010/08/simple-compass-sensormanager-and.html

http://developer.android.com/reference/android/hardware/SensorManager.html

It should be what you are looking for. The OnSensorChanged method should provide the same functionality. (float)event.values[0] - your title.

Just read your thanks text. This is the only way to do this, from everything I have researched, and from my experience in general. For example, I brought you what you need pretty quickly, with copy and paste.

+3
source

If you need a real-time header, you should go with @ jack57's answer and use the G-sensors in the device.

If you only need a heading, when you get a new location, you can get it using Location.getBearing() , but note that this only works with GPS coordinates, if you got the coordinate from LocationManager.NETWORK_PROVIDER , then the bearing will be 0.

+2
source

All Articles