Back to project page blink.
The source code is released under:
Apache License
If you think the Android project blink listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nashlincoln.blink.app; // w ww .j a v a 2 s .co m import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; import com.nashlincoln.blink.R; import com.nashlincoln.blink.content.Syncro; /** * Created by nash on 10/12/14. */ public class NetworkReceiver extends BroadcastReceiver { private static final String TAG = "NetworkReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive"); ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean connected = false; if (networkInfo != null && networkInfo.isConnected()) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo connectionInfo = wifiManager.getConnectionInfo(); String ssid = connectionInfo.getSSID(); ssid = ssid.replaceAll("\"", ""); Log.d(TAG, "ssid: " + ssid + " " + PreferenceUtils.getString(R.string.preference_key_ssid)); connected = ssid.equals(PreferenceUtils.getString(R.string.preference_key_ssid)); } Syncro.getInstance().onConnected(connected); } }