Intent wifiAlwaysAvailable = new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE);
wifiAlwaysAvailable.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(wifiAlwaysAvailable);
I'm trying to enable programatically the Wifi scanning setting to improve accuracy in our location. This code works fine in other devices but in Samsung devices like A5 or S8 this doesn't work. Any idea?
Edited: I try to use the method startActivityForResult
and it works, but you need the Activity context and, in my case I only have the Aplication context.
Finally I found the solution.
I create a transparent activity and I started it where I was trying to start this WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE
. Then I called the method startActivityForResult(new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE),1)
in the onCreate
of this activity.