Unable to solve errors in android?

后端 未结 4 1266
难免孤独
难免孤独 2020-12-21 14:06

I am working on android quiz game. QuestionActivity and EndgameActivity are 2 classes in my game. I want when my game over control transferred to EndgameActivity. For this i

4条回答
  •  时光说笑
    2020-12-21 14:41

    The problem is not that your EndgameActivity cannot be found. The exception:

    ActivityNotFoundException: No Activity found to handle Intent { act=EndgameActivity }
    

    tells you that EndgameActivity is somehow being treated as an action. This is odd because you are neither using the constructor Intent(String):

    Intent i = new Intent("EndgameActivity");
    

    Nor using Intent#setAction(String).

    Try using the fully-qualified class name:

    Intent i = new Intent(com.abc.cyk.QuestionActivity.this,
                                                com.abc.cyk.EndgameActivity.class);
    

    Another thing you can try:

    Intent i = new Intent();
    i.setClass(QuestionActivity.this, com.abc.cyk.EndgameActivity.class);
    startActivity(i);
    finish();
    

    Although its unrelated to your current issue, I noticed that in EndgameActivity#onCreate(Bundle), you're using:

    setContentView(findViewById(R.layout.endgame));
    

    This should be changed to:

    setContentView(R.layout.endgame);
    

提交回复
热议问题