title: Launch activity from background app
body: <p>I have my app running in the background and I want the app to be shown on the top(launched) of the android phone when the code below is ran. (I know the code is ran for sure)</p>
  
  <p>This seems like a simple thing but I spent a couple hours on this site and everyone seems to be suggesting something like this:</p>
  
  <pre><code>Intent intent = new Intent(myActivity.this, myActivity.class);
  startActivity(intent);
  </code></pre>
  
  <p>However, it is not bringing the app to the front and launching it.</p>
  
  <p>I got it to work from a PendingIntent launched from a notification. Which I done by the code below. But I want the app to launch by itself without the user clicking on the notification. </p>
  
  <pre><code>Intent intent = new Intent(myActivity.this, myActivity.class);
  PendingIntent contentIntent = PendingIntent.getActivity(this, REQUEST_CODE, intent, 0);
  notification.setLatestEventInfo(this, "title", "msg", contentIntent);
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>Intent intent = new Intent("android.intent.action.MAIN");
  startActivity(intent);
  </code></pre>
  
  <p>and flagging the intent:</p>
  
  <pre><code>intent.setFlags(Intent.FLAG_FROM_BACKGROUND);
  intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  </code></pre>
  
  <p>But doesn't seem to do anything, any help appreciated.</p>