Вроде есть два приложения с похожей архитектурой. В одном после того, как развернул приложение, появляется в логе onRestart(); onResume(); в другом нет.. свернул приложение, последнее что вижу в логе onStope(); а когда снова разворачиваю - черный экран... и снова сворачиваю - лог не меняется. Почему может такое происходить? в каких случаях не вызываются методы onRestart(); onResume()?
@Override
public void run() {
Canvas canvas;
while(running){
canvas = null;
try{
canvas= this.surfaceHolder.lockCanvas(null);
if (canvas == null)
continue;
synchronized(surfaceHolder){
this.gamePanel.update();
this.gamePanel.onDraw(canvas);
}
} finally{
if(canvas!=null){
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG,"surfaceCreated");
thread.setRunning(true);
thread.start();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG,"surfaceDestroyed");
//посылаем потоку команду на закрытие и дожидаемся,
//пока поток не будет закрыт.
boolean retry = true;
thread.setRunning(false); // ну жна ли эта строка. без нее после сворачивания игры черный экран.
while (retry) {
try {
thread.join();
retry = false;
} catch (InterruptedException e) {
// пытаемся снова остановить поток thread
}
}
}
Вот несколько выдержек из одной умной книжки. может помочь:
The onResume function is executed after the OnStart event or after the current activity is switched to the background. When the user views this activity again, if it has not been destroyed, and if onStop events have not been performed (activities continue to exist in the task)...
After the onStop event is executed, if the activity and the process it resides in have not been systematically destroyed, or if the user views the activity again, the onRestart event(s) of the activity are executed. The onRestart event skips the onCreate event activities and directly executes the onStart events.
:
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Как правильно написать clone(), чтобы все элементы массива также копировались?