Static way to get 'Context' in Android?

前端 未结 19 2692
猫巷女王i
猫巷女王i 2020-11-21 06:36

Is there a way to get the current Context instance inside a static method?

I\'m looking for that way because I hate saving the \'Context\' instance eac

19条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-21 07:21

    No, I don't think there is. Unfortunately, you're stuck calling getApplicationContext() from Activity or one of the other subclasses of Context. Also, this question is somewhat related.

提交回复
热议问题