title: How to bring activity to front from notification in drag down menu?
body: <p>I am working at an application that uses a notification(with a foreground service).</p>
  
  <p>The use case is the following:</p>
  
  <ul>
  <li>If the activity of the application is <em>killed</em>, when clicking on the notification's icon the activity is created and brought to foreground.</li>
  <li>If the activity of the application is <em>not visible</em>, when clicking on the notification's icon the activity is simply brought to foreground.</li>
  </ul>
  
  <p>For re-creating/bringing the activity on foreground I am using the following broadcast receiver in my foreground service:</p>
  
  <pre><code>private static class MyBroadcastReceiver extends BroadcastReceiver{
      @Override
      public void onReceive(Context context, Intent intent) {
          Intent intent = new Intent(context,MainActivity.class)
              .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
              .setAction("android.intent.action.MAIN")
              .addCategory("android.intent.category.LAUNCHER");
          context.startActivity(sIntent);
      }
  }
  </code></pre>
  
  <p>The desired action is pretty much similar to the default music player on an android phone, i.e: when clicking on the icon it's activity is simply brought to foreground(or re-created and brought to foreground in case it was previously killed)</p>
  
  <p>This a screenshot from a Samsung S4</p>
  
  <p><a href="https://i.stack.imgur.com/EwHuPl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EwHuPl.png" alt="Teh screenshot"></a></p>
  
  <ul>
  <li>first notification is from usb - we do not care about it</li>
  <li>second notification is my application - <strong>when clicking on the icon the activity gets created but not brought to foreground</strong>(the user has to swipe back the menu to see the activity)</li>
  </ul>
  
  <p><strong>How can I bring it to front without the additional swipe-back-menu?</strong> (in the similar way how music player app does?</p>
  
  <p>PS: Minimum Android SDK  version is 16</p>