android-connectivitymanager

ConnectivityManager.NetworkCallback() -> onAvailable(Network network) method is not triggered when device connects to a internal wifi network

十年热恋 提交于 2020-01-03 18:04:12
问题 I am trying to send telementary data to App Center on out internal wifi network but it is not sending on this network but it does on any external network. When debugging found that Method onAvailable() is not called when device is connected to internal wifi but it does get called when connected to any external wifi. Below code is from App Center SDK : appcenter\utils\NetworkStateHelper.javaNetworkStateHelper.java. Class NetworkStateHelper -> Method reopen() --> public void onAvailable(Network

ConnectivityManager.NetworkCallback() -> onAvailable(Network network) method is not triggered when device connects to a internal wifi network

。_饼干妹妹 提交于 2020-01-03 18:03:40
问题 I am trying to send telementary data to App Center on out internal wifi network but it is not sending on this network but it does on any external network. When debugging found that Method onAvailable() is not called when device is connected to internal wifi but it does get called when connected to any external wifi. Below code is from App Center SDK : appcenter\utils\NetworkStateHelper.javaNetworkStateHelper.java. Class NetworkStateHelper -> Method reopen() --> public void onAvailable(Network

Perform network-specific host name resolutions using Network.getAllByName

ⅰ亾dé卋堺 提交于 2019-12-24 09:35:45
问题 In the ConnectivityManager documentation, in bindProcessToNetwork javadoc, there is the following comment : Using individually bound Sockets created by Network.getSocketFactory().createSocket() and performing network-specific host name resolutions via Network.getAllByName is preferred to calling bindProcessToNetwork. In OkHttp, there is the setSocketFactory to satisfy the first part of the comment, but I have no idea how/where to use Network.getAllByName to perform the host name resolution.

How to get network state change on android? [duplicate]

只谈情不闲聊 提交于 2019-12-23 05:09:44
问题 This question already has answers here : Android: Internet connectivity change listener (7 answers) Closed last year . I have broadcast receiver for "CONNECTIVITY_CHANGE". When I print the extra using this: intent.getExtras().toString() I can see that if I disable WIFI, I receive 2 network change. WIFI DISCONNECTED MOBILE CONNECTED However, when I try to use NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); It said, this API has been deprecated.

Difference between registerDefaultNetworkCallback and registerNetworkCallback

和自甴很熟 提交于 2019-12-21 07:34:11
问题 I came across registerDefaultNetworkCallback and registerNetworkCallback while updating my Android app for API 28. Having reviewed the documentation, I cannot find the difference between registering a network callback and registering a default network callback . When will one use which? Thanks in advance :) 回答1: As far as I understood, the difference between registerDefaultNetworkCallback and registerNetworkCallback it's only based on customisation. registerDefaultNetworkCallback works

Difference between registerDefaultNetworkCallback and registerNetworkCallback

给你一囗甜甜゛ 提交于 2019-12-21 07:34:04
问题 I came across registerDefaultNetworkCallback and registerNetworkCallback while updating my Android app for API 28. Having reviewed the documentation, I cannot find the difference between registering a network callback and registering a default network callback . When will one use which? Thanks in advance :) 回答1: As far as I understood, the difference between registerDefaultNetworkCallback and registerNetworkCallback it's only based on customisation. registerDefaultNetworkCallback works

Android Q, programmatically connect to different WiFi AP for internet

醉酒当歌 提交于 2019-12-19 02:49:06
问题 As in Android Q, several WiFi APIs are restricted. I am trying to use alternate APIs to connect to different Wifi AP for internet. Below is my code : WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder(); builder.setSsid("wifi-ap-ssid"); builder.setWpa2Passphrase("wifi-ap-password"); WifiNetworkSpecifier wifiNetworkSpecifier = builder.build(); NetworkRequest.Builder networkRequestBuilder1 = new NetworkRequest.Builder(); networkRequestBuilder1.addTransportType

Check internet connection in android (not network connection)

一个人想着一个人 提交于 2019-12-18 07:17:45
问题 I have a problem with checking internet connection in android at runtime. I use some different methods to check internet connection but i don't know which one is better . because each of them have some problems . Method 1 check internet connection by pinging Google : Runtime runtime = Runtime.getRuntime(); try { Process mIpAddressProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8"); int mExitValue = mIpAddressProcess.waitFor(); return mExitValue == 0; } catch (InterruptedException |

ConnectivityManager getNetworkInfo(int) deprecated

≯℡__Kan透↙ 提交于 2019-12-17 03:46:14
问题 Using compileSdkVersion 23 , however trying to support as far back as 9. getNetworkInfo(int) was deprecated in 23. The suggestion was to use getAllNetworks() and getNetworkInfo(Network) instead. However both of these require minimum of API 21. Is there a class that we can use in the support package that can assist with this? I know that a solution was proposed before, however the challenge of my minimum API requirements of 9 poses a problem. 回答1: You can use: getActiveNetworkInfo();

ConnectivityManager.TYPE_WIFI is showing deprecated in code.I had use Network Capabilities in above M version , want to remove warning of deprecated

孤者浪人 提交于 2019-12-11 17:22:58
问题 I want to remove the warning which is showing in the code below m version.I had use below code which is working good but still want to remove the warning which is showing in line ConnectivityManager.TYPE_WIFI.Can below warning be removed which is also showing in kotlin compiler ?? val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager? if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { cm?.run { cm.getNetworkCapabilities(cm.activeNetwork)?.run { if