Skip to content

Commit

Permalink
Fixes onHostResume crash (#202)
Browse files Browse the repository at this point in the history
* Fixes on host resume crash

* Fixes on host resume crash
  • Loading branch information
stoneman1 authored and André Neves committed Jul 27, 2017
1 parent 0adc3e3 commit 1c1e29c
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ private String getOrientationString(int orientation) {
public void onHostResume() {
final Activity activity = getCurrentActivity();

assert activity != null;
if (activity == null) {
FLog.e(ReactConstants.TAG, "no activity to register receiver");
return;
}
activity.registerReceiver(receiver, new IntentFilter("onConfigurationChanged"));
}
@Override
Expand All @@ -164,13 +167,6 @@ public void onHostPause() {

@Override
public void onHostDestroy() {
final Activity activity = getCurrentActivity();
if (activity == null) return;
try
{
activity.unregisterReceiver(receiver);

}
catch (java.lang.IllegalArgumentException e) {
FLog.e(ReactConstants.TAG, "receiver already unregistered", e);
}}
}

0 comments on commit 1c1e29c

Please sign in to comment.