2013年6月26日 星期三

turn on wifi hotspot

You should be able to do it in Android 4.2 make sure you have the permission
android.permission.CHANGE_WIFI_STATE
and we cannot help you unless you post your code.
I believe this will help you check if tethering is active


    WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);

    Method[] methods = wifiManager.getClass().getDeclaredMethods();
    for (Method method : methods) {
        if (method.getName().equals("setWifiApEnabled")) {
            try {
                method.invoke(wifiManager, null, enable);
            } catch (Exception ex) {
            }
            break;
        }
    }
share|improve this answer

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...