File tree Expand file tree Collapse file tree
android/src/main/java/com/devstepbcn/wifi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -186,6 +186,18 @@ Method to force wifi usage. Android by default sends all requests via mobile dat
186186wifi .forceWifiUsage (true );
187187```
188188
189+ Method to get connection status of a forced network (because it takes some time to be set up).
190+ ``` javascript
191+ // Callback returns true if the process of forcing network usage is finished
192+ wifi .connectionStatusOfBoundNetwork ((isBound ) => {
193+ if (isBound) {
194+ console .log (' Network is bound' );
195+ } else {
196+ console .log (' Network isn\' t bound' );
197+ }
198+ });
199+ ```
200+
189201
190202Add a hidden wifi network and connect to it
191203``` javascript
Original file line number Diff line number Diff line change @@ -159,6 +159,18 @@ public void onAvailable(Network network) {
159159 }
160160 }
161161
162+ //Use this method to make sure that your forced network already bound
163+ @ ReactMethod
164+ public void connectionStatusOfBoundNetwork (Callback connectionStatusResult ) {
165+ ConnectivityManager connManager = (ConnectivityManager ) getReactApplicationContext ().getSystemService (Context .CONNECTIVITY_SERVICE );
166+ Network network = connManager .getBoundNetworkForProcess ();
167+ if (network != null ) {
168+ connectionStatusResult .invoke (true );
169+ } else {
170+ connectionStatusResult .invoke (false );
171+ }
172+ }
173+
162174 //Method to check if wifi is enabled
163175 @ ReactMethod
164176 public void isEnabled (Callback isEnabled ) {
You can’t perform that action at this time.
0 commit comments