Reputation: 71
By Network Capabilities I mean - is NR,LTE,CDMA,UMTS,GSM supported? is wifi / mobile data supported? I just want to know if the device is capable of doing the above. I do not need to know the current active network stuff.
https://developer.android.com/reference/android/net/NetworkCapabilities - this api is little helpful but does not completely fulfill my need.
Also I wanted to know if my device has the features like wifi / bluetooth / cellular capabilities?
Upvotes: 0
Views: 252
Reputation: 71
I found a solution to detect hardware capabilities using packetmanager. Ex:
getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
This will help user know if the device is capable of certain feature or not.
Upvotes: 0
Reputation: 4337
I've always used this powerful library in all of my projects :
implementation 'com.blankj:utilcodex:1.29.0'
Usage :
LogUtils.i("NetworkUtils isConnect = %b" , NetworkUtils.isConnected());
LogUtils.i("NetworkUtils isAvailableByPing = %b" , NetworkUtils.isAvailableByPing());
LogUtils.i("NetworkUtils isWifiEnable = %b" , NetworkUtils.getWifiEnabled());
LogUtils.i("NetworkUtils isWifiConnected = %b" , NetworkUtils.isWifiConnected());
LogUtils.i("NetworkUtils is4G = %b" , NetworkUtils.is4G());
LogUtils.i("NetworkUtils getNetworkType = %s", NetworkUtils.getNetworkType());
For more accessibility check the PhoneUtils
& NetworkUtils
classes :
https://github.com/Blankj/AndroidUtilCode
Upvotes: 0