私はSensorEventListenerを実装するクラスにOutOfMemoryErrorを持っています。ここでは、ログでは、時々私は、これは私が持っているログでOutOfMemoryErrorが発生SensorEventListenerのJava android OutOfMemoryError
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
gravity = event.values;
}
if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
geomagnetic = event.values;
}
if (gravity != null && geomagnetic != null) {
float R[] = new float[9];
float I[] = new float[9];
boolean success = SensorManager.getRotationMatrix(R, I, gravity, geomagnetic);
if (success) {
float orientation[] = new float[3];
SensorManager.getOrientation(R, orientation);
float azimuthInRadians = orientation[0];
float azimuthInDegress = (float)Math.toDegrees(azimuthInRadians);
if (azimuthInDegress < 0.0f) {
azimuthInDegress += 360.0f;
}
azimuth = (int) azimuthInDegress;
Hawk.put(HawkConst.AZIMUTH, azimuth);
}
}
}
を持っています。時々私は、このエラーを持っていますが、何も常に
at com.android.internal.util.FastXmlSerializer.<init>(FastXmlSerializer.java:55)
at com.android.internal.util.XmlUtils.writeMapXml(XmlUtils.java:177)
at android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:596)
at android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52)
at android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511)
at android.app.SharedPreferencesImpl.enqueueDiskWrite(SharedPreferencesImpl.java:532)
at android.app.SharedPreferencesImpl.access$100(SharedPreferencesImpl.java:52)
at android.app.SharedPreferencesImpl$EditorImpl.commit(SharedPreferencesImpl.java:454)
at com.orhanobut.hawk.SharedPreferencesStorage.put(SharedPreferencesStorage.java:23)
at com.orhanobut.hawk.Hawk.put(Hawk.java:63)
at pl.***.****.worker.Tracker.onSensorChanged(Tracker.java:154)
at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:474)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:138)
at android.os.Looper.loop(Looper.java:131)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(NativeStart.java)
stacktraceを含む例外を送信できますか? – Loyalar
投稿したコードの行は154行ですか? – Loyalar
@Loyalar Hawk.put(HawkConst.AZIMUTH、方位角); –