Skip to content

Commit

Permalink
Fix multiple triggering issue of NetworkCallback on Android 10
Browse files Browse the repository at this point in the history
  • Loading branch information
weitsai-horizon committed Aug 30, 2023
1 parent de3a782 commit 8ba231c
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1418,11 +1418,22 @@ public void onAvailable(@NonNull Network network) {
@Override
public void onUnavailable() {
super.onUnavailable();
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
connectivityManager.unregisterNetworkCallback(this);
}
if (!resultSent) {
poResult.success(false);
resultSent = true;
}
}

@Override
public void onLost(Network network) {
super.onLost(network);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
connectivityManager.unregisterNetworkCallback(this);
}
}
};

connectivityManager.requestNetwork(
Expand Down

0 comments on commit 8ba231c

Please sign in to comment.