title: NFC detection: either start activity or display dialog
body: <p>I have a <strong>main-activity</strong> which shows some data in a list and a <strong>nfc-asynctask</strong> which reads some data from a card. I want to achieve the following behavior:</p>
  
  <ol>
  <li>If the app is closed and a card is put near the mobile phone, the main-activity and simultaneously the nfc-asynctask should be started. The results of the asynctask should be presented in a dialog.</li>
  <li>If the app is opened and a card is put near, the nfc-asynctask should be restarted and only a dialog with the results should be opened.</li>
  </ol>
  
  <p>My current approach always starts the main-activity. This means that <strong>sometimes, there are multiple instances of my main-activity</strong> and when the user hits the back-button, instead of switching to the home-menu, another activity instance is put on.</p>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>&lt;activity
      ...
      android:launchMode="singleTop"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
          &lt;action android:name="android.nfc.action.TECH_DISCOVERED"/&gt;
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
      &lt;/intent-filter&gt;
      &lt;meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/filter_nfc"/&gt;
  &lt;/activity&gt;
  </code></pre>