search

Home  >  Q&A  >  body text

android - Toast.makeText()报错

方法中第一个参数传application就会报错,改成Activity就不会报错,代码如下:

ProApplication代码如下:

报错如下:

伊谢尔伦伊谢尔伦2772 days ago685

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:09:50

    Is your ProApplication declared in AndroidManifest.xml?
    From the log, it is obvious that the Application tag in your AndroidManifest.xml does not specify your ProApplication, causing the context to be null.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:09:50

    The log only shows that the context you passed in is null. Specifically, you can debug and set the endpoint to see if there is any problem with the incoming.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 09:09:50

    Wang Zhengyi’s correct answer is that ProApplication.context is a null reference object.

    reply
    0
  • Cancelreply