1 回のアクティビティで GPS データと加速度計データを読み取ることはできますか? データを読み込んでテキストビューに入れたい。加速度計のデータは既に読み取っていますが、このコードをアクティビティに追加するとアプリケーションがクラッシュします
public class MainActivity extends Activity implements SensorEventListener {
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
valuesInitialization();
sensorsInitialization();
}
private void valuesInitialization()
{
Config.mContext = this;
mInitialized = false;
mLastAccelerometer[0] = INITVALUE;
mLastAccelerometer[1] = INITVALUE;
mLastAccelerometer[2] = INITVALUE;
mLastGyroscope[0] = INITVALUE;
mLastGyroscope[1] = INITVALUE;
mLastGyroscope[2] = INITVALUE;
mLastOrientation[0] = INITVALUE;
mLastOrientation[1] = INITVALUE;
mLastOrientation[2] = INITVALUE;
}
private void sensorsInitialization()
{
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
mOrientation = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
}
private void registListener()
{
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(this, mOrientation, SensorManager.SENSOR_DELAY_NORMAL);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocationListener);
}
protected void onResume()
{
super.onResume();
registListener();
}
protected void onPause()
{
super.onPause();
mSensorManager.unregisterListener(this);
}
}
問題を解決する方法はありますか?前もって感謝します
エラーログ: