What is context in android?

This question already has an answer here:

  • What's the difference between the various methods to get a Context? 7 answers
  • What is 'Context' on Android? 29 answers

  • This was asked and answered several times.

    Please see this question: What is Context in Android? and the accepted answer: https://stackoverflow.com/a/3572553/1820695

    For differences between various Context accessor methods ( getApplicationContext() , getBaseContext() , this in Activity , etc.) see this question: Android - what's the difference between the various methods to get a Context?


    If we go by the documentation

    Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

    In Simple words its the context of current state of the application/object. It lets newly created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity, package/application)

    For the difference between getApplicationContext() and getBaseContext() please refer this

    链接地址: http://www.djcxy.com/p/91372.html

    上一篇: 我应该在android中的一个方法的参数写什么

    下一篇: android中的上下文是什么?