Open seladev opened 3 years ago
Thanks for reporting this.
If you observe different behavior on two different devices with the same code where the only difference is delay, then this is clearly hardware issue and library cannot do anything about this. It can be also Android OS issue, but still it's not related to the library.
Regards, Piotr
Thanks for your quick answer
When i am listening to wifi changes with BroadcastReceiver i can see that the wifi connection event immediately.
This is the BroadcastReceiver:
receiver = new NetworkChangeReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(receiver, intentFilter); receiver.setConnectionListener(this);
This is the logs: 2021-04-21 11:37:21.943----- NetworkChangeReceiver ###### change network wifi enable = false -------------------- 2021-04-21 11:37:49.358----- NetworkChangeReceiver ###### change network onReceive = android.net.conn.CONNECTIVITY_CHANGE -------------------- 2021-04-21 11:37:49.363----- NetworkChangeReceiver ###### change network wifi enable = true -------------------- 2021-04-21 11:37:49.370----- NetworkChangeReceiver ###### change network onReceive = android.net.conn.CONNECTIVITY_CHANGE -------------------- 2021-04-21 11:37:49.404----- NetworkChangeReceiver ###### change network wifi enable = true -------------------- 2021-04-21 11:38:19.325 Fragment -------------------- ###### change network = Connectivity{state=CONNECTED, detailedState=CONNECTED, type=1, subType=0, available=true, failover=false, roaming=false, typeName='WIFI', subTypeName='', reason='null', extraInfo=''} --------------------
In this receiver you are not using NetworkCapabilities.TRANSPORT_WIFI
. I haven't tested library with this option. When you will use filter(ConnectivityPredicate.hasType(ConnectivityManager.TYPE_WIFI))
in the library, then you will get immediate result as well.
I tried this code filter(ConnectivityPredicate.hasType(ConnectivityManager.TYPE_WIFI))
It is the same behaviour - 30 sec delay
I also tried it with no filter - and It is the same behaviour - 30 sec delay
Describe the bug I am using this code for listening to wifi changes - ReactiveNetwork.observeNetworkConnectivity(context) .subscribeOn(Schedulers.io()) .filter(ConnectivityPredicate.hasType(NetworkCapabilities.TRANSPORT_WIFI)) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ logWarning("###### change network = $it") },{ })
I am testing the code in different devices and its work, but in Google pixel 3a i am receiving the wifi concavity change event in 30 seconds delay. In Samsung device i am receiving the wifi concavity change event immediately
To Reproduce Steps to reproduce the behavior:
Expected behavior The Wifi connect in the same time
Smartphone (please complete the following information):