title: android - notification click - if app closed open activity, if app opened bring show current activity
body: <p>I have a service with an ongoing notification. in the app itself I have two activities - <code>HomeActivity</code> and <code>SettingsActivity</code>.</p>
  
  <p>Currently what I have is -> when the notification is clicked:</p>
  
  <ol>
  <li><p>If the app is closed -> open the <code>HomeActivity</code>.</p></li>
  <li><p>If the current showing activity is <code>HomeActivity</code>, bring it to front without creating a new one.</p></li>
  </ol>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>resultIntent = new Intent(context, HomeActivity.class);
  resultPendingIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  
  Notification notification = mBuilder
                  .setSmallIcon(notificationData.getImageSrc())  // the status icon
                  .setTicker("HealthChecker")  // the status text
                  .setWhen(System.currentTimeMillis())  // the time stamp
                  .setContentTitle("HealthChecker")  // the label of the entry
                  .setContentText(notificationData.getText())  // the contents of the entry
                  .setOngoing(true).setContentIntent(resultPendingIntent)
                  .build();
  </code></pre>
  
  <p><strong>Manifest:</strong> I added `android:launchMode="singleTop":</p>
  
  <pre><code>&lt;activity
              android:name=".ui.HomeActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
              android:label="@string/app_name"
              android:launchMode="singleTop"
              android:theme="@style/AppTheme.NoActionBar"&gt;&lt;/activity&gt;
  </code></pre>
  
  <p>The problem I have is:</p>
  
  <p>when I am in the <code>SettingsActivity</code> and I click the notification, it opens a new instance of <code>HomeActivity</code>.</p>
  
  <p>What I want is when the <strong>app is opened in either activity</strong> and notification is clicked -> show current activity, and if <strong>app is closed</strong> and notification is clicked, open new instance of <code>HomeActivity</code>.</p>