使用Activity参数在类内部的Android Override方法

时间:2012-11-09 13:15:02

标签: android methods android-activity override

我想知道我是否通过这种方式将我的活动放到其他课程中:

public class GateActivity extends MapActivity {

private Presenter assistant = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    assistant = new Presenter(this);
// ...
}

另一个班级:

public class Presenter {
private android.app.Activity act;

public Presenter(android.app.Activity a){
    this.act = a;
    // ...
}

如果在“Presenter”类中可以创建这样的意图:

intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intent.setType("image/*");
act.startActivityForResult(intent, 1);

AND创建/处理其“覆盖onActivityResult(...)”方法:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    switch (requestCode){
    case 1: // ...
}

提前致谢! ;)

1 个答案:

答案 0 :(得分:0)

是的,这应该有用。

当被叫活动完成后,将调用GateActivity.onActivityResult()