主界面代码
package com.xiake.seng;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.btn);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
//通过startActivityForResult传送数据,同时MainActivity不失联
Intent intent = new Intent(this, ActivityA.class);
intent.putExtra("main1", new int[] { 2, 3 });
startActivityForResult(intent, 2);
}
//获取其他通过startActivityForResult方法启动的界面的值
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)