title: Multiple Intent flags for starting a new Activity in Android
body: <p>I'm trying to add more flags at an Intent for launching a new Activity inside a BroadcastReceiver, responding to a particular intent sent from another part of the app.
  I've added as I noticed by the LogCat messages the <code>FLAG_ACTIVITY_NEW_TASK</code> flag at the Intent I created and then other ones but I get the same error in LogCat as the <code>FLAG_ACTIVITY_NEW_TASK</code> was not there.</p>
  
  <p>Here's the code:</p>
  
  <pre><code> public class actReceiver extends BroadcastReceiver {
   ...
      public void onReceive(Context context, Intent intent) {
      ...
       else if (intent.getAction().equals("something")) {
                  Intent prefAct = new Intent(context, PreferencesActivity.class)
                  prefAct.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                         .setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
                         .setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
                         .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                  startActivity(prefAct);
              }
       ... }
  ... }
  </code></pre>
  
  <p>And the particular LogCat error:</p>
  
  <pre><code>Caused by: 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>