private void onMaxAttemptsReached() {
    if (!isResumed) {
      finish();
      return;
    }

    String errorMsg =
        Phrase.from(this, R.string.unable_to_connect_to_soft_ap)
            .put("device_name", getString(R.string.device_name))
            .format()
            .toString();

    new AlertDialog.Builder(this)
        .setTitle(R.string.error)
        .setMessage(errorMsg)
        .setPositiveButton(
            R.string.ok,
            new OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                startActivity(new Intent(DiscoverDeviceActivity.this, GetReadyActivity.class));
                finish();
              }
            })
        .show();
  }
 @Override
 public String getListEmptyText() {
   return Phrase.from(this, R.string.empty_soft_ap_list_text)
       .put("device_name", getString(R.string.device_name))
       .format()
       .toString();
 }
  private void showProgressDialog() {
    wifiListFragment.stopAggroLoading();

    String msg =
        Phrase.from(this, R.string.connecting_to_soft_ap)
            .put("device_name", getString(R.string.device_name))
            .format()
            .toString();

    connectToApSpinnerDialog = new ProgressDialog(this);
    connectToApSpinnerDialog.setMessage(msg);
    connectToApSpinnerDialog.setCancelable(false);
    connectToApSpinnerDialog.setIndeterminate(true);
    connectToApSpinnerDialog.show();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_discover_device);

    softAPConfigRemover = new SoftAPConfigRemover(this);
    softAPConfigRemover.removeAllSoftApConfigs();
    softAPConfigRemover.reenableWifiNetworks();

    DeviceSetupState.previouslyConnectedWifiNetwork = WiFi.getCurrentlyConnectedSSID(this);

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    sparkCloud = ParticleCloud.get(this);

    wifiListFragment = Ui.findFrag(this, R.id.wifi_list_fragment);
    ConnectToApFragment.ensureAttached(this);

    resetWorker();

    Ui.setText(
        this,
        R.id.wifi_list_header,
        Phrase.from(this, R.string.wifi_list_header_text)
            .put("device_name", getString(R.string.device_name))
            .format());
    Ui.setText(
        this,
        R.id.msg_device_not_listed,
        Phrase.from(this, R.string.msg_device_not_listed)
            .put("device_name", getString(R.string.device_name))
            //                        .put("setup_button_identifier",
            // getString(R.string.mode_button_name))
            //                        .put("indicator_light", getString(R.string.indicator_light))
            //                        .put("indicator_light_setup_color_name",
            // getString(R.string.listen_mode_led_color_name))
            .format());

    Ui.setTextFromHtml(this, R.id.action_troubleshooting, R.string.troubleshooting)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Uri uri = Uri.parse(v.getContext().getString(R.string.troubleshooting_uri));
                startActivity(WebViewActivity.buildIntent(v.getContext(), uri));
              }
            });

    if (sparkCloud.getAccessToken() == null) {
      Ui.setText(
          this,
          R.id.logged_in_as,
          Phrase.from(this, R.string.you_are_logged_in_as)
              .put("username", sparkCloud.getLoggedInUsername())
              .format());
      Ui.findView(this, R.id.action_log_out)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  sparkCloud.logOut();
                  log.i("logged out, username is: " + sparkCloud.getLoggedInUsername());
                  startActivity(new Intent(DiscoverDeviceActivity.this, LoginActivity.class));
                  finish();
                }
              });
    } else {
      Ui.findView(this, R.id.action_log_out).setVisibility(View.INVISIBLE);
    }

    Ui.findView(this, R.id.action_cancel)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                finish();
              }
            });
  }