android-wifi
Best way to evaluate connection speed
Facebook released a library for this: https://github.com/facebook/network-connection-class this wasn’t existing in 2011..
Send request over Mobile data when WIFI is ON.(Android L)
Well finally found solution for this. Trick was to use capability as NET_CAPABILITY_INTERNET. Which is same as startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_HIPRI); See the Firmware design here builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR); After this I am able to get onAvailable callback from system and later I set my process default network as mobile data. Hence all the request goes over mobile … Read more
How to mock Context using Mockito?
Context context = mock(Context.class);
How to get available wifi networks and display them in a list in android
You need to create a BroadcastReceiver to listen for Wifi scan results: private final BroadcastReceiver mWifiScanReceiver = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { List<ScanResult> mScanResults = mWifiManager.getScanResults(); // add your logic here } } } In onCreate() you would assign mWifiManager and initiate a scan: mWifiManager = … Read more
SCAN_RESULTS_AVAILABLE_ACTION return empty list in Android 6.0
As of Android 6.0, permission behaviour has changed to runtime. To use a feature that requires a permission, one should check first if the permission is granted previously. Using checkSelfPermission(permissionString) method a result is returned, wither ther permission is PERMISSION_GRANTED or PERMISSION_DENIED. If permission isn’t granted or it is first time, a request for permission … Read more