});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//先判断是哪个页面返回过来的
switch (requestCode) {
case REQUEST_A:
//再判断返回过来的情况,是成功还是失败还是其它的什么……
switch (resultCode) {
case ActivityA.RESULT_SUCCESS:
//成功了
break;
case ActivityA.RESULT_FAILED:
//失败了
break;
}
break;
case REQUEST_B:
//同上……
break;
}
}
}
接下来是ActivityA.java,这个类里面具体处理一件事情。然后成功失败,把结果返回到MainActivity里面就行了。
复制代码
public class ActivityA extends Activity {
public static final int RESULT_SUCCESS = 0;
public static final int RESULT_FAILED = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//找控件各种……
//我正在干些事情,修改数据啊,各种啊。
//假设数据提交失败了
boolean result = false;










