Skip to content

Commit

Permalink
fix(wifi_iot): multiple triggering issue of NetworkCallback on Androi…
Browse files Browse the repository at this point in the history
…d 10 (#344)
  • Loading branch information
weitsai committed Sep 4, 2023
1 parent de3a782 commit b7b61fc
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 b7b61fc

Please sign in to comment.