我编写了游戏,应该在应该显示分数的 Activity 上使用.startActivity
,问题是,我没有正确显示 Activity ,而是得到“已弃用的线程”不支持方法”。我用谷歌搜索了这个错误,并删除了应用程序中的所有 Thread.stop()
,但它没有帮助。还有其他原因导致我收到此类错误吗?
public class GameFrame extends Activity implements OnTouchListener, OnLossListener {
Panel game;
@Override
public void onCreate(Bundle savedInstanceState) {
Display d=getWindowManager().getDefaultDisplay();
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Point p=new Point(d.getWidth(),d.getHeight());
game=new Panel(this,p);
setContentView(game);
game.setOnTouchListener(this);
game.setOnLossListener(this);
}
public boolean onKeyDown (int kc,KeyEvent ke){
if (kc==23){
game.shoot();
}
return true;
}
public void onPause(){
super.onPause();
game.thread.setState(false);
game.mech.setState(false);
this.finish();
}
@Override
public boolean onTouch(View v, MotionEvent me) {
if (v.equals(game)){
game.setPosOfPlane((int)me.getX());
}
return true;
}
@Override
public void lost(int score) {
Intent i=new Intent (this,EndGame.class);
i.putExtra("score",score+"");
startActivity (i);
}
}
最佳答案
使用Thread.currentThread().interrupt();而是 stop();
希望对你有帮助!
关于java - 如果没有 stop() 方法,则不支持已弃用的线程方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9341769/