2012-02-10 78 views

回答

14

只需使用下面的代码块:

Intent intent=new Intent(); 
intent.putExtra("RESULT_STRING", string); 
setResult(RESULT_OK, intent); 
finish(); 

GET值从这个意图在onActivtyResult方法调用活动:

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == CREATE_REQUEST_CODE) { 
     if (resultCode == RESULT_OK) { 
     //Use Data to get string 
     String string = data.getStringExtra("RESULT_STRING"); 
     } 
    } 
} 
1

documentation说明了一切。您通过调用setResult来设置结果,并在onActivityResult方法中读取它。

1

你只需要putExtraintent和呼叫setResult()

Intent data = new Intent(); 
data.putExtra("myobj", value); 
setResult(Activity.RESULT_OK, data); 
相关问题