connectivity= connectivityservice.getinstance (context);
Servicemanager.addservice (context.connectivity_service,connectivity);
Among them connectivityservice.getinstance (context); Corresponds to Frameworks/base/services/java/com/android/server/connectivityservice.java
Now look at the Connectivityservice.java in the
for (int nettype:mprioritylist) {
Switch (Mnetattributes[nettype].mradio) {
Case Connectivitymanager.type_wifi:
SLOG.V (TAG, "Startingwifi Service.");
Wifistatetracker WST = Newwifistatetracker (context, Mhandler);
Wifiservice Wifiservice = Newwifiservice (context, WST);
Servicemanager.addservice (Context.wifi_service,wifiservice);
Wifiservice.startwifi ();//Start Wifiservice
Mnettrackers[connectivitymanager.type_wifi] = WST;
Wst.startmonitoring ();//Start monitoring
Mwifienabler = new Wifienabler (this, (checkboxpreference) findpreference ("Enable_wifi"));
Mnotifyopennetworks =(checkboxpreference) findpreference ("Notify_open_networks");
Mnotifyopennetworks.setchecked(secure.getint (getcontentresolver (),secure.wifi_ Networks_available_notification_on, 0) = = 1);
Some examples of use in Android Java