Static way to get 'Context' in Android?

前端 未结 19 2685
猫巷女王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:24

    I think you need a body for the getAppContext() method:

    public static Context getAppContext()
       return MyApplication.context; 
    

提交回复
热议问题