add method to determine if current activity is null

Reviewed By: andreicoman11

Differential Revision: D2680281

fb-gh-sync-id: ac158fb55dd60d05b7e3444d68e06a010e04eef4
This commit is contained in:
Peter Lai 2015-11-23 10:47:06 -08:00 committed by facebook-github-bot-9
parent 90de853cc1
commit 56a56f33d1
1 changed files with 5 additions and 3 deletions

View File

@ -225,15 +225,17 @@ public class ReactContext extends ContextWrapper {
}
}
public boolean hasCurrentActivity() {
return mCurrentActivity != null;
}
/**
* Same as {@link Activity#startActivityForResult(Intent, int)}, this just redirects the call to
* 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 boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
if (mCurrentActivity == null) {
return false;
}
Assertions.assertNotNull(mCurrentActivity);
mCurrentActivity.startActivityForResult(intent, code, bundle);
return true;
}