Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getScanResults not working on Nexus 5 with Android 6.0.1 #90

Open
llioor opened this issue Jul 21, 2016 · 17 comments
Open

getScanResults not working on Nexus 5 with Android 6.0.1 #90

llioor opened this issue Jul 21, 2016 · 17 comments

Comments

@llioor
Copy link

llioor commented Jul 21, 2016

Hi,
The plugin works wonderfully (setWifiEnabled, addNetwork, connectNetwork, disconnectNetwork, etc.)

startScan calls the success callback, but getScanResults always calls the success callback with an empty array.

we have used an androidManifest with the following pemissions:

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

Any ideas?

@llioor
Copy link
Author

llioor commented Jul 23, 2016

@hoerresb Any chance to get an answer please?

@leitzsin360
Copy link

leitzsin360 commented Jul 29, 2016

AFTER enable GPS .it is ok.
Its a bug in Andorid 6+

@llioor
Copy link
Author

llioor commented Jul 30, 2016

Even with GPS enabled it is not working..
getScanResults still calls the success callback with an empty array.
Any advice?

@leitzsin360
Copy link

I test ok.
and I commented the following lines in file WifiWizard.java

//
//
// if(!displayLocationSettingsRequest()){
// callbackContext.error("Android 6 and above Gps turned off");
// }
//
// if(!checkCurrentPermissions()){
// callbackContext.error("permission not found") ;
// }

@leitzsin360
Copy link

I tested ok.
and I commented the following lines in file WifiWizard.java

//
//
// if(!displayLocationSettingsRequest()){
// callbackContext.error("Android 6 and above Gps turned off");
// }
//
// if(!checkCurrentPermissions()){
// callbackContext.error("permission not found") ;
// }

1 similar comment
@leitzsin360
Copy link

I tested ok.
and I commented the following lines in file WifiWizard.java

//
//
// if(!displayLocationSettingsRequest()){
// callbackContext.error("Android 6 and above Gps turned off");
// }
//
// if(!checkCurrentPermissions()){
// callbackContext.error("permission not found") ;
// }

@digitalWestie
Copy link

hey, I've got the same issue here Nexus 5 with Android 6.0.1

@digitalWestie
Copy link

OK, I turned my GPS on and it didn't work. But when I went into Settings -> App -> My App -> Permissions and allowed location it worked. Very odd one.

@byrcz17
Copy link

byrcz17 commented Sep 16, 2016

hey, this problem is solved?? I try run in android 6.x with turned GPS, and it didn't work... Any idea?

@emcniece
Copy link

Just worked through this - manually enabling the Location permission as @digitalWestie mentioned made the networks show up.

The branch at https://github.com/paraggarg37/WifiWizard contains a check for GPS enable, but the app itself doesn't complain when Location is off. I'm going to try and use http://ionicframework.com/docs/v2/native/diagnostic/ to see if I can get a better indication of available services.

@zhangdongming0607
Copy link

Well,I tried with xiaomi5. At first,I got an empty array as well.But when the access of using location and wifi is allowed ,I can get the correct list. Just like @emcniece says ,manually enable the access to location and wifi is necessary(default is ask when used).

@peeter-tomberg
Copy link

You have to ask for permissions at runtime. I used the plugin https://github.com/dpa99c/cordova-diagnostic-plugin to achieve this. Before calling getScanResults, I call window.cordova.plugins.diagnostic.requestLocationAuthorization(successCallback, errorCallback);

Please note that successCallback does not mean the user granted you permissions, it might also mean the user denied your permission. Read more at: https://github.com/dpa99c/cordova-diagnostic-plugin#requestlocationauthorization

@tyleha
Copy link

tyleha commented Jan 12, 2017

Confirmed that I needed to enable Location permissions in Android 6.0.1 to get getScanResults to work. I now request these permissions programatically with cordova-plugin-android-permissions

@RavikiranCK
Copy link

@leitzsin360 That was pain before I got to know the fact..Thank you for saving my head..Pretty frustrating when there's no exception or things go normally without expected output..

@pflugs30
Copy link

@peeter-tomberg I'm trying to do what you described in your comment on Android version 7.0.0. However, I'm getting a "Permission permanently denied" response on the call to requestLocationAuthorization. Did you encounter anything like that?

I also notice that the phone never prompts me to enable the permission. I'm currently testing my app using cordova run android via USB debugging. I was also unable to find my app in the settings to manually enable the permissions. I suspect (thought I don't know for sure) I am being blocked by not having the app actually installed on my device, just debugging via cordova. Any ideas on what to check? Thank you.

@StrongLucky
Copy link

@pflugs30 I just had the same problem. But I found my problem. I clickt "never show again". I fully deinstalled the app. Now the app ask again. Maybee this will help you.

To request the permission is only run diagnostic.requestLocationAuthorization()

@mhossam2008
Copy link

You have to make sure that your app is using both coarse and fine location permissions and make sure that wifi "and GPS surprisingly" is turned on , that's an odd bug , but that's how things worked for me after couple of hours of trouble shooting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests