detect wifi status automatically in Android -
detect wifi status automatically in Android -
in app have known wifi status automatically user connected wifi or not without user action. want observe when user doesn't utilize app. there way? i'm new android.
the best worked me:
androidmanifest
<receiver android:name="com.aedesign.communication.wifireceiver" > <intent-filter android:priority="100"> <action android:name="android.net.wifi.state_change" /> </intent-filter> </receiver>
broadcastreceiver class
public class wifireceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { networkinfo info = intent.getparcelableextra(wifimanager.extra_network_info); if(info != null) { if(info.isconnected()) { // work. // e.g. check network name or other info: wifimanager wifimanager = (wifimanager)context.getsystemservice(context.wifi_service); wifiinfo wifiinfo = wifimanager.getconnectioninfo(); string ssid = wifiinfo.getssid(); } } } }
on recive gets called automatically.
android android-wifi
Comments
Post a Comment