android-wifi

What is the difference between active scan and passive scan?

我是研究僧i 提交于 2019-12-05 15:16:51
问题 What is the difference between mWifiManager.startScanActive() and mWifiManager.startScan() . What is the difference between active scan and passive scan ? 回答1: Passive scanning listens to beacons sent by the access points. That means waiting for the beacon to be sent (usually a few seconds). An active scanning will emit probes to those APs immediately. 回答2: please note that an active scan will consume more energy and as "ordinary" wifi access points broadcast their beacons several times per

Android WifiManager getScanResult complains Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission although declared permission

早过忘川 提交于 2019-12-05 09:51:25
I am developing an App to check Wifi points. I am getting error "java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results" at wifiManager.getScanResults() even though I already declared those permissions. main activity public class MainActivity extends AppCompatActivity { WifiManager wifiManager; String[] wifis; WifiReceiver wifiReceiver; ListView wifiListView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); wifiListView = (ListView) findViewById(R

Using Android phone as wifi web server

≡放荡痞女 提交于 2019-12-05 09:07:12
I got this crazy idea that I don't know is possible or not... what I want to do is set up my phone as wifi access point, then allow people to connect to it, but handle all incoming http traffic myself. So: phone wifi in access point mode; open wifi network (this tidbit works - yes I know it's not officially supported but then I have no intention to distribute put this app on the open market or so, it works on my phone and that's good enough for me). client can connect to the phone (e.g. my laptop: this also works). when client tries to open an http connection to any random server, this has to

How to create wifi tethering Hotspot in Android Marshmallow?

假装没事ソ 提交于 2019-12-05 07:52:22
I've tried to create a Wi-Fi tethering hotspot in Android Marshmallow using the following code. public class WifiAccessManager { private static final String SSID = "1234567890abcdef"; public static boolean setWifiApState(Context context, boolean enabled) { //config = Preconditions.checkNotNull(config); try { WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (enabled) { mWifiManager.setWifiEnabled(false); } WifiConfiguration conf = getWifiApConfiguration(); mWifiManager.addNetwork(conf); return (Boolean) mWifiManager.getClass().getMethod(

Is it possible to add a network configuration on Android Q?

我只是一个虾纸丫 提交于 2019-12-05 07:34:22
Background I've noticed that in WifiManager class there is a function called addNetwork , that might be useful if I want to restore or save networks information (network name AKA SSID, together with the password and the type), so that I could also connect to it. The problem I can't find much information about how to do such a thing. I've seen various examples on StackOverflow, and if I target Android API 28 (or below), I indeed succeed to make it add a network and even connect to it. When targeting Android 29 (Android Q), however, it fails to add the network. What I've found Since I'm trying

Setting wifi ssid with a space in it

亡梦爱人 提交于 2019-12-05 06:27:19
I am trying to setup the wifi on my android things raspberry pi following the documentation . My Ssid contains a space in the name let's say "my ssid". I tried to put quotes around it like this: $ adb shell am startservice \ -n com.google.wifisetup/.WifiSetupService \ -a WifiSetupService.Connect \ -e ssid "my ssid" \ -e passphrase secretpassword When looking at the logcat for the wifi connection I see: WifiNetworkHistory: saving network history: "my"NONE gw: null Network Selection-status: NETWORK_SELECTION_ENABLED ephemeral=false choice:null link:0 status:2 nid:0 hasEverConnected: false

How send data through WiFi?

帅比萌擦擦* 提交于 2019-12-05 05:06:10
问题 In my Application I want to send files through WiFi to multiple users if they are using the same WiFi connection Without TCP. how to get the list of the users who are connected to a specified wify. I have tried with Samples But I didn't get anything . 回答1: Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point (Android's Wi-Fi P2P framework complies with the Wi

Why does having Wifi on but not connected help Network location, when using LocationManager?

回眸只為那壹抹淺笑 提交于 2019-12-05 04:58:10
This is possibly off-topic for SO, if so I apologise (and gladly accept the flag for closure), but I'm having issues figuring out why when WIFI is on, but not connected to any access point (on my android device), it vastly improves the accuracy of network provider when using LocationManager . Without it on, the general network location result is about 1 mile away from my current position. Also, most of the time the lat/lng values returned are different, so it's not even that it requested once and just cached the result in lastKnownLocation() Obviously I'm using both GPS and Network providers

Android - Passing simple string over Wi-fi?

牧云@^-^@ 提交于 2019-12-05 04:11:35
问题 I have Wi-fi direct demo. In that we can transfer any image files to other devices. When another device get connected and it shows to send image from gallery. And at other side it shows sent image. But I want to send a simple string and at other side I want to toast that string. Here I am posting a code in which they have implemented file transfer. I am very confused in this code. I am not getting where to change to pass only string. Please help me. Thanks. DeviceDetailFragment.java /** * A

Android Find the device's ip address when it's hosting a hotspot

天大地大妈咪最大 提交于 2019-12-05 02:49:55
I need to find the device's ip address when it's hosting a hotspot. I've used this code so far : //if is using Hotspot for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); if (intf.getName().contains("wlan")) { for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && (inetAddress.getAddress().length == 4)) { return inetAddress.getHostAddress(); } } } } This works