search

Home  >  Q&A  >  body text

android - getApplication() 和 getApplicationContext()返回的有什么不同?

getApplicationContext()和getApplication()返回的是Androidmanifest.xml中<application>标签对应的类的实例么?
它们有什么不同?

PHPzPHPz2803 days ago567

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:23:46

    getApplicationContext()返回的是应用的全局上下文,它随着应用的退出而销毁。getApplication()返回的是应用applicationExample.

    reply
    0
  • PHPz

    PHPz2017-04-17 17:23:46

    Somewhat similar to the difference between activity and context, one is the context of the application and the other is the instance of the application

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:23:46

    It’s the same, but the place of use is different.

    reply
    0
  • 阿神

    阿神2017-04-17 17:23:46

    getApplication() returns the instance of application,
    getApplicationContext returns the application context.
    The application context exists in the getApplication() instance

    reply
    0
  • Cancelreply