如果您想在不恢复破坏活动的情况下传递数据,那么您必须为此设置监听器..
public class MyFirstActivity extends Activity implements OnDataChanged {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onChange(int a) {
Log.e("", "a : " + a);
}
}
MySecondActivity.java
public class MySecondActivity extends Activity {
private OnDataChanged mOnDataChanged;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sendData(10);
}
public interface OnDataChanged {
public void onChange(int a);
}
private void sendData(int a) {
mOnDataChanged.onChange(a);
}
}
MySecondActivity 通过实现 MySecondActivity 的侦听器向 MyFirstActivity 发送 10...