1

How can I programatically check phone is wifi capable?

I'm NOT talking about enabling/disabling wifi. I want to get the presence of a wifi hardware/driver

Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236

2 Answers2

4

boolean hasWifi = PackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI);

PackageManager p = ctx.getPackageManager();
boolean hasWifi = p.hasSystemFeature(PackageManager.FEATURE_WIFI);

Check the documentation for further hardware constants that you can test. ctx is a Context instance.

Edit: Sniff, forgot the correct way to use it, fixed my example.

  • PackageManager.FEATURE_WIFI is from API Level 8 on-wards, any other way to check it on level 7? – Mithun Sreedharan Oct 13 '11 at 10:23
  • I don't know one from the top of my head, but I never needed such a feature for myself. Maybe someone else knows more. –  Oct 13 '11 at 10:28
1
    PackageManager manager = getPackageManager();
    FeatureInfo info[] = manager.getSystemAvailableFeatures();
    for(int i=0; i<info.length; i++){
        if(((info[i].name)!=null)&&(info[i].name).equals("android.hardware.wifi")){
            Toast.makeText(getBaseContext(), "Support wifi", Toast.LENGTH_LONG).show();

hope this will help you

Sabin
  • 21
  • 4