public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//accel
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
setContentView(R.layout.sample);
}
///////////////// Basics
/**
* Called when the application is in the background
*/
public void onPause()
{
super.onPause();
sensorManager.unregisterListener(this);
//this is important because Android applications
//do not close, they are in the background
//so resources would be hogged otherwise
}
/**
* Called when the application is started
* or in the foreground again
*/
public void onResume()
{
super.onResume();
sensorManager.registerListener(this, sensor, rate);
}
//==================Accel=====================
/**
* Called when the values of the acceleration sensor changes
*
* @param e Details about the change
*/
public void onSensorChanged(SensorEvent e)
{
float azimuth=e.values[0];
Log.i("azimuth",String.valueOf(azimuth));
}
/**
* Called when accuracy of the sensor is changed
*
* @param sen Which sensor's accuracy changed
* @param acc The new accuracy degree
*/
public void onAccuracyChanged(Sensor sen, int acc)
{
}
ここで、センサーマネージャーを使用して方位角値を取得しています。方位角値を使用してコンパスのようにimageviewを回転させる方法を知りたいですか?誰かが何かアイデアを与えることができますか?ここでOnDraw関数を使用する方法は?OnDrawメソッド内に円または線を描画せずに?