Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an android device is equipped with a wifi adapter?

Of course the vast majority of android devices support wifi but not all of them.

How could someone check to see if the wifi is supported on the current device?
For instance with bluetooth you could just do (in Scala):

def isBluetoothSupported: Boolean = {
  BluetoothAdapter.getDefaultAdapter match {
    case null => false;
    case x: BluetoothAdapter => true;
  }
}

What is the corresponding code for wifi?

like image 711
George Pligoropoulos Avatar asked Dec 20 '22 05:12

George Pligoropoulos


1 Answers

I don't know Scala, but the relevant API call is:

getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)

The above would allow you to detect whether wifi is available at runtime.

While not directly relevant to your question, another option that might be of use is the "uses-feature" tag element. Adding something like the following to your manifest would filter your application out on Google Play for devices without wifi:

<uses-feature android:name="android.hardware.wifi" android:required="true" />
like image 154
ajh158 Avatar answered May 08 '23 14:05

ajh158