2015年10月15日 星期四

Start another Activity and Get Back the Result

If:
A start B,B give back the information to A

A start B

At A activity

A start B


Intent intent = new Intent(this,actB.class);
startActivityForResult(intent,0);


Reecive the information from B, onActivityResult

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

    }


At B activity

B send back the information and close

Intent i =new Intent();
i.putExtra("name","Roy");
setResult(0,i);
 finish();