title: Run AsyncTask from another activity
body: <p>I have a button in my launcher activity which is menu.java and when I click said button I want it to load the other activity MainActivity.java and run the AsyncTask in said actvity without having to click another button. </p>
  
  <p>This is my menu.java activity: </p>
  
  <pre><code>package davidgb.baseballspain;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.View;
  import android.widget.Button;
  
  public class Menu extends ActionBarActivity implements View.OnClickListener{
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_menu);
  
      Button beis = (Button) findViewById(R.id.beis);
  
      beis.setOnClickListener(this);
  
  }
  
  @Override
  public void onClick(View view) {
      switch (view.getId()){
          case R.id.beis:
              Intent intent1 = new Intent(this, MainActivity.class);
              startActivity(intent1);
              Intent myIntent = new Intent(this, MainActivity.doit.class);
              startActivity(myIntent);
              //new MainActivity.doit().execute();
              break;
  
          default:
              break;
      }
  
  
  }
  }
  </code></pre>
  
  <p>The thing is when i click the button in the menu.java it loads the MainActivity but it doesn't run the AsyncTask directly, it just crashes. Im new to coding, any advice will be highly appreciate.</p>
  
  <p>Edit: Fixed this by creating a new class and implementing the AsyncTask there.</p>