title: How can i call startActivity() to use ACTION_SEND from a different class
body: <p>I'm trying to build an Android plugin to extend the ACTION_SEND functionality, but when i'm trying to call the activity to share a plain text using:</p>
  
  <pre><code>context.startActivity(Intent.createChooser(mIntent, title));
  </code></pre>
  
  <p>i get this error:</p>
  
  <pre><code>ERROR/AndroidRuntime(838): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
  </code></pre>
  
  <p>The thing is, that in my last line of code i have FLAG_ACTIVITY_NEW_TASK implemented.
  Here is my code:</p>
  
  <pre><code>public class ShareMenu{
  private Context context;
  
  
  public ShareMenu(Context context){
      this.context = context;
  
  }
  
  public static void buildHomeShareMenu(Context context) {
      Intent mIntent = new Intent(android.content.Intent.ACTION_SEND);
      mIntent.setType("text/plain");
      mIntent.putExtra(Intent.EXTRA_TEXT, mtitle);
      mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      context.startActivity(Intent.createChooser(mIntent, mtitle));
  
  }
  </code></pre>
  
  <p>I've tried to call just startActivity passing the instance mIntent, and works, but even i've noted if you just do these you can call other activities, but i can't figure it out how can i can pass the static Intent.</p>
  
  <p>Thanks in advance.</p>