Android Open Source - EZ-Wifi-Notification Hardware






From Project

Back to project page EZ-Wifi-Notification.

License

The source code is released under:

GNU General Public License

If you think the Android project EZ-Wifi-Notification listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package et.nWifiManager;
//from w  w  w  . j  a va2  s  . c  o  m
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;

public class Hardware {

  private static final String TAG = "HardwareConnector";
  
  /**
   * Gets the state of Airplane Mode.
   * 
   * @param context
   * @return true if enabled.
   */
  @SuppressWarnings("deprecation")
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  public static boolean isAirplaneModeOn(Context context) {
    Log.v(TAG, "Checking Flight-Mode");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      Log.d(TAG, "Checking FlightMode (JELLY_BEAN_MR1 API)");
      return Settings.Global.getInt(context.getContentResolver(),
          Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
    } else {
      Log.d(TAG, "Checking FlightMode (depreceated API)");
      return Settings.System.getInt(context.getContentResolver(),
          Settings.System.AIRPLANE_MODE_ON, 0) != 0;
    }
  }

  public static String getSSID(Context context) {
    try {
      return ((WifiManager) context
          .getSystemService(Context.WIFI_SERVICE))
          .getConnectionInfo().getBSSID();
    } catch (Exception ex) {
      return "";
    }
  }

  @SuppressLint("DefaultLocale")
  public static String getIP(Context context) {
    try {
      WifiManager wifiManager = (WifiManager) context
          .getSystemService(Context.WIFI_SERVICE);
      WifiInfo wifiInfo = wifiManager.getConnectionInfo();
      int ipAddress = wifiInfo.getIpAddress();

      return String.format("%d.%d.%d.%d", (ipAddress & 0xff),
          (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff),
          (ipAddress >> 24 & 0xff));
    } catch (Exception ex) {
      // TODO Notify me
      return "";
    }
  }

  public static String WifiName(Context context) {
    try {
      WifiManager wifiMgr = (WifiManager) context
          .getSystemService(Context.WIFI_SERVICE);
      WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
      return wifiInfo.getSSID();
    } catch (Exception ex) {
      return "";
    }
  }

}




Java Source Code List

et.nWifiManager.AnalyzeService.java
et.nWifiManager.ConnectivityBroadcastReceiver.java
et.nWifiManager.Constants.java
et.nWifiManager.Hardware.java
et.nWifiManager.LauncerActivity.java
et.nWifiManager.MyApplication.java
et.nWifiManager.PreferencesActivity.java
et.nWifiManager.Analyzers.AnalyzerInterface.java
et.nWifiManager.Analyzers.BrutalAnalyzer.java
et.nWifiManager.Analyzers.ContextWrapperIntentAnalyzerBase.java
et.nWifiManager.Analyzers.IntentAnalyzerInterface.java
et.nWifiManager.Analyzers.IntentAnalyzer.java
et.nWifiManager.Message.Message.java
et.nWifiManager.Message.Messages.java
et.nWifiManager.Notificators.NotificationSettings.java
et.nWifiManager.Notificators.Notificator.java
et.nWifiManager.Notificators.SystemNotificator.java
et.nWifiManager.conState.ConnectionStatusEnum.java