How to get my activity context?

前端 未结 7 1742
小鲜肉
小鲜肉 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:12

    Ok, I will give a small example on how to do what you ask

    public class ClassB extends Activity
    {
    
     ClassA A1 = new ClassA(this); // for activity context
    
     ClassA A2 = new ClassA(getApplicationContext());  // for application context. 
    
    }
    

提交回复
热议问题