@Override
 protected void onStart() {
   super.onStart();
   if (!wifiManager.isWifiEnabled()) {
     onWifiDisabled();
   }
 }
  @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();
              }
            });
  }
 @Override
 protected void onPause() {
   super.onPause();
   isResumed = false;
 }
 @Override
 protected void onResume() {
   super.onResume();
   isResumed = true;
 }