我从我的球员那里得到了很多ANR-s。 这是ANR的样子......
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 obj=0x75646598 self=0xf4d76500
| sysTid=20631 nice=0 cgrp=default sched=0/0 handle=0xf7465d54
| state=R schedstat=( 0 0 0 ) utm=259988 stm=3107 core=4 HZ=100
| stack=0xff21a000-0xff21c000 stackSize=8MB
| held mutexes= "mutator lock"(shared held)
at cr.logics.runfishrun2.S3DSurfaceView.onSensorChanged (S3DSurfaceView.java:292)
at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent (SystemSensorManager.java:579)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:323)
at android.os.Looper.loop (Looper.java:143)
at android.app.ActivityThread.main (ActivityThread.java:7230)
at java.lang.reflect.Method.invoke! (Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
"Signal Catcher" daemon prio=5 tid=2 Runnable
| group="system" sCount=0 dsCount=0 obj=0x32c180a0 self=0xf3f84000
| sysTid=20636 nice=0 cgrp=default sched=0/0 handle=0xf43dc930
| state=R schedstat=( 0 0 0 ) utm=2 stm=5 core=1 HZ=100
| stack=0xf42e0000-0xf42e2000 stackSize=1014KB
| held mutexes= "mutator lock"(shared held)
这是我的代码..
public void onSensorChanged ( SensorEvent event )
{
if ( event.sensor.getType ( ) == Sensor.TYPE_ACCELEROMETER )
{
final float x = event.values[0] ;
final float y = event.values[1] ;
final float z = event.values[2] ;
// Get a free pool item, else allocate a new one
//
AccelerometerEventRunnable oAccelerometerEventRunnablePoolItem = null ;
for ( AccelerometerEventRunnable aer : aAccelerometerEventRunnablePool )
{
if ( aer.done ( ) )
{
oAccelerometerEventRunnablePoolItem = aer ;
oAccelerometerEventRunnablePoolItem . set ( x, y, z, iDisplayOrient ) ;
break ;
}
}
if ( oAccelerometerEventRunnablePoolItem == null )
{
oAccelerometerEventRunnablePoolItem = new AccelerometerEventRunnable ( x, y, z, iDisplayOrient ) ;
aAccelerometerEventRunnablePool.add ( oAccelerometerEventRunnablePoolItem ) ;
//Log.d ( "S3DSurfaceView", "onAccelerometerEvent: " + aAccelerometerEventRunnablePool.size() ) ;
}
if ( oAccelerometerEventRunnablePoolItem != null )
{
queueEvent ( oAccelerometerEventRunnablePoolItem ) ;
}
}
else if ( event.sensor.getType ( ) == Sensor.TYPE_ORIENTATION )
{
final float azimuth = event.values[0] ;
final float pitch = event.values[1] ;
final float roll = -event.values[2] ;
queueEvent ( new Runnable ( ) { public void run ( ) { if ( oRenderer != null ) oRenderer.onHeadingEvent ( azimuth ) ; } } ) ;
}
}
看起来就像这一行...... for(AccelerometerEventRunnable aer:aAccelerometerEventRunnablePool)
问题是它不是我的代码,我不知道如何解决这个问题。任何解决方法? 提前谢谢!