android - supplicant connection change doesn't trigger -


i want when wifi connection established. have broadcastreceiver works prefectly receiving network_state_changed_action , scan_results_available_action, not supplicant_connection_change_action. 1 harder test: turn off/on router that.

    protected void oncreate(bundle savedinstancestate) {      receiverwifi = new wifireceiver();             intentfilter intentfilter = new intentfilter();             intentfilter.addaction(wifimanager.supplicant_connection_change_action);             intentfilter.addaction(wifimanager.network_state_changed_action);             intentfilter.addaction(wifimanager.scan_results_available_action);             registerreceiver(receiverwifi, intentfilter);     //...     }       class wifireceiver extends broadcastreceiver {             public void onreceive(context c, intent intent) {                 final string action = intent.getaction();                  log.d("mhp","*broadcastreceiver: " + action")} 

and manifiest.xml

  <application         a..         <activity             android:name=".mainactivity"             android:label="@string/app_name">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <action android:name="android.net.wifi.scan_results" />                 <action android:name="android.net.wifi.supplicant.connection_change" />                 <action android:name="android.net.wifi.state_change" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity> 

and androidmanifest.xml:

  <application         a..         <activity             android:name=".mainactivity"             android:label="@string/app_name">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <action android:name="android.net.wifi.scan_results" />                 <action android:name="android.net.wifi.supplicant.connection_change" />                 <action android:name="android.net.wifi.state_change" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity> 

on connecting wifi network if don't supplicant_connection_change_action, network_state_changed_action , can play action needs.

in broadcast receiver, this:

string action = intent.getaction(); if (wifimanager.network_state_changed_action.equals(action)) {     networkinfo netinfo = intent.getparcelableextra(wifimanager.extra_network_info);     wifimanager wifimanager = (wifimanager) context.getsystemservice(context.wifi_service);     if ( (netinfo.getdetailedstate()==(networkinfo.detailedstate.connected)) )     {         // wifi connected, want     } } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -