开发者

How to programatically check phone is wifi capable?

How can I programatically check phone is wifi capable?

I'm NOT talking about enabling/disa开发者_如何学编程bling wifi. I want to get the presence of a wifi hardware/driver


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 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜