Java 当按下Home(主页)或Back(返回)按钮时,应用程序崩溃
所以,当我按下Home按钮或Back按钮时,我的应用程序崩溃。我不知道如何解决这个问题。救命啊Java 当按下Home(主页)或Back(返回)按钮时,应用程序崩溃,java,android,Java,Android,所以,当我按下Home按钮或Back按钮时,我的应用程序崩溃。我不知道如何解决这个问题。救命啊 public class Game extends SurfaceView implements SurfaceHolder.Callback { public Game(Context context) { super(context); getHolder().addCallback(this); gameContext = context; } ... publi
public class Game extends SurfaceView implements SurfaceHolder.Callback {
public Game(Context context) {
super(context);
getHolder().addCallback(this);
gameContext = context;
}
...
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
updateThread.setRunning(false);
while (retry) {
try {updateThread.join();
retry = false; }
catch (InterruptedException e) {
}
}
}
}
下面是我按下Home按钮时的过程日志:
07-15 07:43:47.333: I/ActivityManager(285): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 285
07-15 07:43:47.673: W/WindowManager(285): Screenshot failure taking screenshot for (290x515) to layer 21015
07-15 07:43:48.013: D/gralloc(36): Registering a buffer in the process that created it. This may cause memory ordering problems.
07-15 07:43:48.043: I/ARMAssembler(36): generated scanline__00000077:03010104_00008004_00000000 [ 84 ipp] (103 ins) at [0x4296eea0:0x4296f03c] in 599261 ns
07-15 07:43:48.464: D/gralloc(36): Registering a buffer in the process that created it. This may cause memory ordering problems.
07-15 07:43:48.504: I/ActivityManager(285): Config changes=1480 {1.0 310mcc260mnc en_US ldltr sw360dp w360dp h567dp 320dpi nrml port finger -keyb/v/h tball/v s.8}
07-15 07:43:48.574: I/InputReader(285): Reconfiguring input devices. changes=0x00000004
07-15 07:43:48.574: I/InputReader(285): Device reconfigured: id=0, name='qwerty2', size 720x1280, orientation 0, mode 1, display id 0
07-15 07:43:49.003: I/Choreographer(560): Skipped 168 frames! The application may be doing too much work on its main thread.
07-15 07:43:49.343: D/PhoneStatusBar(560): mSettingsPanelGravity = 55
07-15 07:43:49.593: D/dalvikvm(560): GC_FOR_ALLOC freed 7091K, 51% free 7087K/14336K, paused 111ms, total 131ms
07-15 07:43:49.743: W/WindowManager(285): Window freeze timeout expired.
07-15 07:43:49.743: W/WindowManager(285): Force clearing orientation change: Window{41ada620 u0 NavigationBar}
07-15 07:43:49.824: I/WindowManager(285): Screen frozen for +2s101ms due to Window{41ada620 u0 NavigationBar}
07-15 07:43:50.194: I/Choreographer(560): Skipped 124 frames! The application may be doing too much work on its main thread.
07-15 07:43:50.803: I/Choreographer(400): Skipped 119 frames! The application may be doing too much work on its main thread.
07-15 07:43:51.783: I/Choreographer(400): Skipped 106 frames! The application may be doing too much work on its main thread.
07-15 07:43:52.493: I/Choreographer(560): Skipped 194 frames! The application may be doing too much work on its main thread.
07-15 07:43:53.105: W/IInputConnectionWrapper(799): showStatusIcon on inactive InputConnection
07-15 07:43:54.173: D/dalvikvm(285): GC_EXPLICIT freed 3158K, 52% free 5244K/10724K, paused 5ms+11ms, total 134ms
尝试释放不使用时占用内存的资源,您可以在onPause()方法中执行此操作 您还可以在manifiest.xml文件中进行如下更改
<activity android:name="your.package.name.YourActivity" android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" android:screenOrientation="landscape">
...
...
“尝试释放资源”-如何释放?”)关于第二条建议-它不适用于我的应用程序。。。