假设我有一个名为
A
的类,定义如下:class A {
Activity c;
public A(Activity c) {
this.c = c;
// do something
}
public void dosomething() { }
}
我有一个像这样定义的Activity:
public class MyActivity extends AppCompatActivity {
@Inject A myObject;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myObject.dosomething();
}
}
我该如何将当前活动提供给我的对象?