title: Android onNewIntent() not triggered when activity is invisible
body: <p>I have 2 activities, first one being MainActivity. In Manifest launch mode of Second Activity is set as <strong>SingleInstance</strong>.The button in MainActivity starts SecondActivity, which has a button which triggers notification. The only problem is <strong>onNewIntent()</strong> method of SecondActivity is not called when SecondActivity is not visible.Why isn't the <strong>onNewIntent()</strong> method not called when app is in background or SecondActivity is invisble to the user?</p>
  
  <p>Code:</p>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.globemaster.com.trials"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"
         &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".SecondActivity"
              android:launchMode="singleInstance"
              android:parentActivityName=".MainActivity"/&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <p>MainActivity.java:</p>
  
  <pre><code> Intent intent=new Intent(MainActivity.this,SecondActivity.class);
   startActivity(intent);
  </code></pre>
  
  <p>SecondActivity.java:</p>
  
  <pre><code>public class SecondActivity extends AppCompatActivity {
      int count=0;int id=3;Notification notification;
      NotificationManager notificationManager;
      Intent intent,intent1;
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.layout_second);
          findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  count++;
                  intent1=new Intent(getApplicationContext(),SecondActivity.class);
                  if (count&gt;1){
                      intent1.putExtra("click",true);
                      }
                  PendingIntent pendingIntent=PendingIntent.getActivity(getApplicationContext(),0,intent1,PendingIntent.FLAG_UPDATE_CURRENT);
                  if (notificationManager==null)
                  {
                      notificationManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                      }
                  Notification.Builder builder=new Notification.Builder(getApplicationContext());
                  builder.setSmallIcon(R.drawable.ic_launcher_background);
                  builder.setContentTitle("My Notification");
                  builder.setContentText("You have "+count+" message");
                  builder.setContentIntent(pendingIntent);
                  notification=builder.build();
                  notificationManager.notify(3,notification);
                  }        });
      }
      @Override
      protected void onNewIntent(Intent intent) {
          super.onNewIntent(intent);
          Log.e("OnNewIntent","Called");
          if (intent!=null&amp;&amp;intent.hasExtra("click")&amp;&amp;intent.getBooleanExtra("click",false))
          {
              Toast.makeText(getApplicationContext(), "Notification Clicked", Toast.LENGTH_SHORT).show();
          }
          else {
              Toast.makeText(getApplicationContext(), "False", Toast.LENGTH_SHORT).show();
          }
      }
  }
  </code></pre>