最終更新:2012-10-14 (日) 10:50:04 (2909d)  

Activity.startActivityForResult
Top / Activity.startActivityForResult

Launch an activity for which you would like a result when it finished. When this activity exits, your Activity.onActivityResult() method will be called with the given requestCode. Using a negative requestCode is the same as calling Activity.startActivity(Intent) (the activity is not launched as a sub-activity).

void startActivityForResult(Intent intent, int requestCode)
void startActivityForResult(Intent intent, int requestCode, Bundle options)

動作

  • (呼び出し元)Activity.startActivityForResultで呼び出す
    void startActivityForResult(Intent intent, int requestCode)
    void startActivityForResult(Intent intent, int requestCode, Bundle options)
  • (呼び出し先)Activity.onCreate - 呼び出される
  • (呼び出し先)Activity.setResultで値を返す
    void setResult(int resultCode)
    void setResult(int resultCode, Intent data)
    • インテントを送り返すことも可能。
  • (呼び出し元)Activity,onActivityResult?で戻された値を取得
    void onActivityResult(int requestCode, int resultCode, Intent data)