title: How i can refresh the same activity in static method
body: <p>My application need to close the activity and open it directly using refresh activity or open new activity and back to the activity ?</p>
  
  <pre><code>public class MainActivity extends Activity {
      static TextView messageBox;
      static String x="";
      static Context context;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
           messageBox=(TextView)findViewById(R.id.messageBox);
           check();
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
  
       public static void updateMessageBox(String msg,String from)
          {
              messageBox.append(msg);
              //Get parent phone number from database
              //check parent number with ...
              if(msg.equals("enable wifi"))
              {
                  x="yes";
              }
              //context.startActivity(new Intent(context, MainActivity.class));
  
              Intent i=new Intent(context, p1.class);
              context.startActivity(i);
  
            }
  
       private void check()
       {
  
           if(x.equals("yes"))
           {
               WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                wifi.setWifiEnabled(true);
           }
  
       }
  
  
  }
  </code></pre>
  
  <p>i'm using open new activity and back to the activity but work crash for application  !!</p>
  
  <p>please help me??</p>