開始一個新的活動,我需要從一個線程調用類新的活動是這樣的:
Intent i = new Intent(getContext(),GameOver.class);
,當我打電話startActivity(i)
它給了我一個錯誤說,該方法是不確定我的課。
任何人都可以告訴我如何解決這個問題?
謝謝!
這裏是線程的完整運行方法:從一個線程
/*starts running the thread*/
@Override
public void run(){
while(run){
Canvas c = null;
try {
c = surfaceHolder.lockCanvas(null);
synchronized (surfaceHolder) {
if (mode == STATE_RUNNING){
/*if user has no more lives, he lost*/
if(Global.lives == 0) lose();
doDraw(c);
}
}
} finally {
// do this in a finally so that if an exception is thrown
// during the above, we don't leave the Surface in an
// inconsistent state
if (c != null) {
/*unlocks the canvas and shows the image drawn by the doDraw method*/
surfaceHolder.unlockCanvasAndPost(c);
}
}
哪裏lose();
是誰的代碼是在啓動(意向)的方法。
請發表您的完整代碼 –
發送廣播或移動處理的新活動開始到主線程的邏輯 – EpicPandaForce
我想這樣做,但也許有一個更簡單的方法。 – Pavle37