devstepbcn / react-native-android-wifi

A react-native module for viewing and connecting to Wifi networks on Android devices.
ISC License
212 stars 121 forks source link

loadWifiList() is returning a null wifiStringList even there are available connections ! #12

Closed DinukaManohara closed 6 years ago

DinukaManohara commented 7 years ago

RN 0.44.0 CLI 2.0.1 Android 7.0 EMUI 5.0 (Huawei GR5 2017) All the other methods are working perfectly but this loadWifiList() is returning a null list ???

rfw commented 7 years ago

@DinukaManohara Some android systems need to open up a list of the wifi available on the phone's GPS

jdeibe commented 7 years ago

@dan-me I'm having the the same issue. No list of wi-fi from method loadWifiList(). What should be added to make it work?

rfw commented 7 years ago

@jdeibe What is the version of Android? Do you have to open the phone GPS?

jdeibe commented 7 years ago

RN 0.45.1, Android 7.0, Honor from Huawei. I just noticed once I turn on GPS/Position from settings in my app it works. I would suggest to add code for permission to use GPS. I still don't understand why I need GPS permission..

rfw commented 7 years ago

@jdeibe https://issuetracker.google.com/issues/37060483

ParthBarot-BoTreeConsulting commented 7 years ago

Thanks @dan-me , we are already using this permission but this would help someone who is using this module.

@jdeibe We are using the following, and its working fine.

    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
SirNeuman commented 6 years ago

I had this same problem even after adding the permissions. Then I went into my app settings on my device and went into permissions. I realized that the "location" permission for my app was toggled to off. This permission did not even appear before I added the "ACCESS_FINE_LOCATION" permission, but for some reason it did not ask me to grant this permission in the app when I added it. I toggled it on in the settings and now i do get the list.

Edit: If you use the React-Native's PremssionsAndroid module and use PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); the app will ask you if you'd like to grant permission in the app the next time you use it.

tolik85 commented 6 years ago

@SirNeuman Thanks! This was exactly my problem!

tripflex commented 6 years ago

Yup I can confirm this is specifically related to the ACCESS_FINE_LOCATION, which I only figured out through numerous trial and errors on a cordova plugin I forked for managing WiFi: https://github.com/tripflex/WifiWizard2/pull/8

tolik85 commented 6 years ago

My app keeps crashing saying there's no ACCESS_FINE_LOCATION in the AndroidManifest, although it is there. Also, as @SirNeuman said, the location permission for my app in Android settings was toggled off and the app was not asking for user's permission with PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);, but crashes instead (until I manually turn the location toggle on). Why is that?

stephane-r commented 6 years ago

Hi guys ! Anyone have solution about this problem ? I'm on Huawai, API 27

ParthBarot-BoTreeConsulting commented 6 years ago

I assume you have tried all the above permissions.

One thing you can check is, which version you are on and does it work for older Android versions? Like, we have tested this on Android 7, not sure in new versions!

Thanks

stephane-r commented 6 years ago

Hi @ParthBarot-BoTreeConsulting

Yes, you can see my AndroidManifest :

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus"/>

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

I try on Huawai P20 with Android 8.