Fix crash when double launching activity

Reviewed By: AaaChiuuu

Differential Revision: D2633573

fb-gh-sync-id: c47bec903d54c12f4d9e576ad1aaf16d4bd68f30
This commit is contained in:
Peter Lai 2015-11-09 14:55:16 -08:00 committed by facebook-github-bot-8
parent 666706b0da
commit de4cb7d403
1 changed files with 7 additions and 3 deletions

View File

@ -227,10 +227,14 @@ public class ReactContext extends ContextWrapper {
/**
* Same as {@link Activity#startActivityForResult(Intent, int)}, this just redirects the call to
* the current activity.
* the current activity. Returns whether the activity was started, as this might fail if this
* was called before the context is in the right state.
*/
public void startActivityForResult(Intent intent, int code, Bundle bundle) {
Assertions.assertNotNull(mCurrentActivity);
public boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
if (mCurrentActivity == null) {
return false;
}
mCurrentActivity.startActivityForResult(intent, code, bundle);
return true;
}
}