I'm developing an app without GUI. It should start it's service when Wifi button is changed(ON or OFF). This is my manifest file:
<receiver android:name="com.updater.wifitester.NetWatcher">
<intent-filter
android:priority="100">
<action
android:name="android.net.wifi.WIFI_STATE_CHANGED"
android:enabled="true"
/>
</intent-filter>
</receiver>
Here is the permissions that I gave:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
And I extended Broadcast receiver:
public class NetWatcher extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
//check intents and service to know if all is ok then set bWifiStateOk accordingly
Toast.makeText(context, "Wifi on", Toast.LENGTH_LONG).show();
Log.i("wifi_state_changed","wifi changed...");
} else {
return ; // do nothing ... we're not in good intent context doh !
}
}
}
But there is nothing in the log cat and no Toasts shown. What Am I missing? Please help me guys...