Exemplo n.º 1
0
  private void updateTile() {
    if (isEnabled()) {
      WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
      WifiInfo wifiInfo = wifiManager.getConnectionInfo();

      if (wifiInfo != null) {
        // if wifiInfo is not null, set the label to "hostAddress"
        InetAddress address = NetworkUtils.intToInetAddress(wifiInfo.getIpAddress());
        mLabel = address.getHostAddress();
      } else {
        // if wifiInfo is null, set the enabled label without host address
        mLabel = mContext.getString(R.string.quick_settings_network_adb_enabled_label);
      }
      mDrawable = R.drawable.ic_qs_network_adb_on;
    } else {
      // Otherwise set the disabled label and icon
      mLabel = mContext.getString(R.string.quick_settings_network_adb_disabled_label);
      mDrawable = R.drawable.ic_qs_network_adb_off;
    }
  }