Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: onResume in MainActivity not called
    primarykey
    data
    text
    <p>My app has a <strong>mainactivity</strong> ...</p> <pre><code> public class MainActivity extends Activity { GameView gameView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); gameView = new GameView(this); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(gameView); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. // we dont know yet tho return true; } @Override protected void onPause() { super.onPause(); gameView.gameLoopThread.onPause(); } @Override protected void onResume() { super.onResume(); gameView.gameLoopThread.onResume(); } } </code></pre> <p>and the <strong>gameLoopThread</strong> is</p> <pre><code> public class GameLoopThread extends Thread { private GameView view; private boolean isRunning = false; static final long FPS = 32; private boolean mPaused = false; private Object mPauseLock; public GameLoopThread(GameView view) { this.view = view; mPauseLock = new Object(); } public void setIsRunning(boolean isRunning) { this.isRunning = isRunning; } @SuppressLint("WrongCall") @Override public void run() { long ticksPS = 1000 / FPS; long startTime; long sleepTime; while (isRunning) { Canvas c = null; startTime = System.currentTimeMillis(); try { c = view.getHolder().lockCanvas(); synchronized (view.getHolder()) { view.onDraw(c); } } finally { if (c != null) { view.getHolder().unlockCanvasAndPost(c); } } sleepTime = ticksPS - (System.currentTimeMillis() - startTime); try { if (sleepTime &gt; 0) sleep(sleepTime); else sleep(10); } catch (Exception e) { } synchronized (mPauseLock) { while (mPaused) { try { mPauseLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } } } public void onPause() { synchronized (mPauseLock) { mPaused = true; } } public void onResume() { synchronized (mPauseLock) { mPaused = false; mPauseLock.notifyAll(); } } } </code></pre> <p>anyway the <code>onResume()</code> in the mainActivity isn't getting called: I determined this by putting a breakpoint there. so the game pauses when i exit the app, but when i return to the app, it's just a paused screen of the game and it doesn't resume again: I want it to resume when i re-enter the app (using the recent application screen). Here is the logcat in case there's anything of signifance.</p> <pre><code>12-22 21:39:09.382: I/System.out(10992): Sending WAIT chunk 12-22 21:39:09.402: I/dalvikvm(10992): Debugger is active 12-22 21:39:09.582: I/System.out(10992): Debugger has connected 12-22 21:39:09.592: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:09.792: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:09.985: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:10.185: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:10.392: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:10.592: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:10.795: I/System.out(10992): waiting for debugger to settle... 12-22 21:39:10.994: I/System.out(10992): debugger has settled (1313) 12-22 21:39:12.343: D/dalvikvm(10992): threadid=1: still suspended after undo (sc=1 dc=1) 12-22 21:42:21.922: W/ActivityThread(11454): Application com.dotdodge is waiting for the debugger on port 8100... </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload