Unable to solve errors in android?

后端 未结 4 1267
难免孤独
难免孤独 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:31
    Check your manifest file you register activity
    android.content.ActivityNotFoundException: No Activity found to handle Intent {     act=EndgameActivity }
    
    0 讨论(0)
  • 2020-12-21 14:36

    i am going through your code, remove findViewById from your code

    setContentView(findViewById(R.layout.endgame));
    
    0 讨论(0)
  • 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);
    
    0 讨论(0)
  • 2020-12-21 14:47

    Addyour EndGame Activity in the manifest file. Logcat clearly says

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

    Just add the EndgameActivity in the manifest file inside a new activity tag.

    0 讨论(0)
提交回复
热议问题