Mutually exclusive relationships When you turn on WiFi and hotspots

Source: Internet
Author: User

WiFi and hotspot cannot be turned on at the same time:

So when you turn on WiFi, you need to close the hotspot first, turn off the WiFi


To turn hotspots on and off:

/** * WiFi hotspot switch. WiFi and hotspot cannot be opened at the same time, so you need to turn off hotspot when WiFi is turned on * * @author jiangping.li * @return * @since MT 1.0 * * Public Boole        An setwifiapenabled (Boolean enabled) {Method method1 = null;        Set hot Spot method by reflection call; try {method = Mwifimanager.getclass (). GetMethod ("setwifiapenabled", Wificonfiguration.class            , Boolean.type);            Wificonfiguration apconfig = null;                if (enabled) {//open hotspot, configure Config, omitted here.                Apconfig = new Wificonfiguration ();            ....                ....            }        Returns the Hotspot setting state return (Boolean) Method.invoke (Mwifimanager, Apconfig, false);        } catch (Nosuchmethodexception e) {//TODO auto-generated catch block E.printstacktrace ();        } catch (IllegalArgumentException e) {e.printstacktrace ();        } catch (Illegalaccessexception e) {e.printstacktrace (); } catch (INvocationtargetexception e) {e.printstacktrace ();    } return true; }


To turn WiFi on and off:

Public Boolean setwifiapenabled (Boolean enabled) {    mwifimanager.setwifienabled (enabled);      return enabled;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mutually exclusive relationships When you turn on WiFi and hotspots

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.