2011-11-01 66 views
0

我用意圖來調用另一個活動。之後,我使用第二個活動從用戶那裏收集了一些數據。我需要在第一個活動中更新一些數據並關閉第二個活動。如何獲得初始意向的類的上下文

因此,我需要第一個活動的Context(這個)。我怎麼做?或者是否需要再次開始第一個活動作爲新活動?

回答

3

使用startActivityForResult()不完成()的第一個活動。你會降落到該活動的方法onActivityResult().

編輯:

Intent intent = new Intent(this,SecondActivity.class); 
startActivityForResult(intent, RESULT_OK); 

public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (resultCode == RESULT_OK) { 
     // When you are back from second Activity you are land here .. 
     // do what ever you want to, without re Creating the this Activity 
    } 
}