android-wifi

Android 6.0.1 couldn't enable wifi hotspot programmatically

非 Y 不嫁゛ 提交于 2019-12-09 05:46:46
问题 When I tried to enable wifi tethering from the following code it throws the exception java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com..... .... not granted this permission: android.permission.WRITE_SETTINGS But this works fine in android 6.0 and below versions. And also tried with giving android.permission.WRITE_SETTINGS too. Is there any limitation in accessing wifiAP in android 6.1? Follow I attached the code sample that I used to enable

FIXED: Can't connect to adb over wifi

江枫思渺然 提交于 2019-12-09 03:32:22
问题 It turns out that adbd Insecure was, in fact, the problem. When I disabled it (by running the app and unchecking Enable insecure adbd , I was able to connect just fine over wifi. Also, for those who are interested, once this was working then netstat -n did show the connection, i.e.: $ netstat -n Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN tcp 0 0 **192.168.0.169:5555** 192.168.0.50:51178 ESTABLISHED tcp6 0 0 ::ffff:127.0.0.1:47514 :::* LISTEN

How to handle network change between wifi and mobile data?

大城市里の小女人 提交于 2019-12-09 00:24:41
问题 I am building a VoIP app.During a VoIP call when user switches between WiFi to mobile data i have a problem handling the scenario. In my call screen activity I have registered for receiver which helps me get notified about the network change scenarios. This is the code which I am using for detecting change in networks in the onRecieve Method. conn_name is private class level variable holding previous connection name. ConnectivityManager connectivity_mgr = ((ConnectivityManager) context

How to detect if a network is (configured as) a mobile hotspot on Android?

左心房为你撑大大i 提交于 2019-12-08 23:30:11
问题 As of Android 4.1, your device can detect if it's connected to a mobile hotspot (given that the mobile hotspot is also running Android 4.1 or higher). Also, you have the option to flag networks as mobile hotspots (under Settings / Data Usage / Overflow menu / Mobile Hotspots). But how do I detect this as a -user- I meant developer? It's not stored in the WifiConfiguration, so where is it? Some context: I want to build a simple tool for Android that checks if you are connected to a network

Wakelock and wifilock not working

会有一股神秘感。 提交于 2019-12-08 17:41:35
问题 I have read plenty of tutorial and posts here on SO regarding the use of WakeLock and WifiLock, but still didn't get to a solution of my issue. I'm writing an app that has, when you start it, the only effect of creating and starting a (foreground) service. This service run two threads that are an UDP broadcast listener (using java.io) and a TCP server (using java.nio). In the onCreate of the service I acquire a wakelock and a wifilock, and I release them in the onDestroy. Everything works

Why my access from my mobile to my computer network doesn't work?

限于喜欢 提交于 2019-12-08 15:00:35
问题 I have a problem and it is that, yesterday, I could access from my mobile phone to my computer network but today it doesn't work. Why it could be? What I have ready: I have running my local server with XAMPP (I have started Apache and MySQL ). I'm connect via WIFI to the same network. My mobile phone it's connect to the computer via USB. I went to CMD , copy the IP of my computer and put it on the browser of my mobile phone, but it doesn't work. I tried with the url 10.0.2.2 but it also doesn

How to measure latency in a wifi network java android

本小妞迷上赌 提交于 2019-12-08 13:44:42
问题 I am developing a mobile app, I need some parameters to implement the algorithm, and I do not know how to measure latency in a wifi network. Some people says using ping, but I do not know how implement this. This is my first question, I am learning. Thank you. 回答1: Please have a look at this answer it might be what you are after you might want to try the following code sample to measure time to do something String host = "172.16.0.2"; int timeout = 3000; long beforeTime = System

Start new wifi scan after finishing the current scan

旧巷老猫 提交于 2019-12-08 11:22:06
问题 I am trying to make an apps that will store all wifi BSSID and RSS into an SQLite Database. (my SQLite table named "scanres" here is part of my code on my onCreate() : wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); //jgn lupa manifest xml nya kasih permission!!! if (wifi.isWifiEnabled() == false) { wifi.setWifiEnabled(true); } x = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { results = wifi.getScanResults(); size = results.size(); if (size

Keep checking if Device has internet connection

被刻印的时光 ゝ 提交于 2019-12-08 10:10:42
问题 As title states I wanted to ask, how can I keep checking if the device has internet connection? I use the following class: import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; public class checkConnection { private static checkConnection instance = new checkConnection(); static Context context; ConnectivityManager connectivityManager; NetworkInfo wifiInfo, mobileInfo; boolean connected = false; public static

How I can check android device is connected to the Internet? [duplicate]

笑着哭i 提交于 2019-12-08 10:10:41
问题 This question already has answers here : How to handle “no internet connection” scenario when sending requests? (2 answers) Closed 2 years ago . Is there any way to find out that android device is connected to the Internet or not. I use this function: public boolean isDeviceOnline() { ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); } but