android.app.Application cannot be instantiated due to NullPointerException

后端 未结 3 944
失恋的感觉
失恋的感觉 2020-11-30 12:51

I\'m kind of a noob in the android world, and doing a pet project for exercising. It\'s a very simple reminder-like app with just two activities. One is a customized ListVie

3条回答
  •  时光取名叫无心
    2020-11-30 13:06

    I did some more tests and lockon the problem in the anonymous inner class for Back button, since the error will appear whenever I clicked this before restarting the app. If I switch activities using the "go back" button on the phone, everything is fine.

    I added one line in the inner class

    EditEntry.this.finish();
    

    It does solve the problem. I tried to test it more systematical this time. Let's say the code without the above line is A, and the code with this line is B. Scenario goes like follow

    1.run A then A --> Error

    2.run A then B --> Error

    3.run B then A --> OK

    4.run B then B --> OK

    Therefore, I assume it is some kind of problem about the activity stack?

提交回复
热议问题