title: Problem in app after hitting the back button (Wifi state)
body: <p>Problem Description:</p>
  
  <p>my app has a main window. when you click a button it make sure you are connected to wifi or 3g, if not it pop up a dialog that enables wifi.
  when wifi is on and the button is clicked a new screen shows up. when you hit the back button, disable wifi and click that button again it does not ask for wifi again and the screen shows up without wifi....</p>
  
  <p>In the Click event of the button i have:</p>
  
  <pre><code> if(chosedOption == curOption)
              {
                  if(network)
                  {
                      target = CurrencyMain.class;
                      go.setAnimation(a);
                  }
                  else
                      askForWifi();
              }
  </code></pre>
  
  <p>and in the askForWifi method i have:</p>
  
  <pre><code>public void askForWifi()
   {
      is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected();
      isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
      network = is3g||isWifi;
       if(!network)
          {    
           AlertDialog alertbox = new AlertDialog.Builder(MainWindowYuval.this).create();
           alertbox.setMessage("Enable wifi of 3g!");
           alertbox.setButton("cancel", new DialogInterface.OnClickListener() {  
                  @Override  
                  public void onClick(DialogInterface dialog, int which) {  
                      dialog.dismiss();                      
                  }  
              });  
  
           alertbox.setButton2("Turn wifi on", new DialogInterface.OnClickListener() {  
                  @Override  
                  public void onClick(DialogInterface dialog, int which) {
                      WifiManager wifiManager = (WifiManager) MainWindowYuval.this.getSystemService(Context.WIFI_SERVICE);
                      wifiManager.setWifiEnabled(true);                     
                  }  
              });
  
           alertbox.show();
  
          }
          is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected();
          isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
          network = is3g||isWifi;
  
   }
  </code></pre>
  
  <p>what can i do to fix this?</p>