How to get my activity context?

前端 未结 7 1739
小鲜肉
小鲜肉 2020-12-02 08:49

I don\'t really get the idea behind how this whole thing works really, so if I have some class A that need the context of a class B which extends <

7条回答
  •  天命终不由人
    2020-12-02 09:11

    You can create a constructor using parameter Context of class A then you can use this context.

    Context c;

    A(Context context){ this.c=context }

    From B activity you create a object of class A using this constructor and passing getApplicationContext().

提交回复
热议问题