title: Intent filter activity and proper show of notifications
body: <p>I'm writing Media files share application.</p>
  
  <p>Now it is divided into 2 parts:</p>
  
  <pre><code>&lt;application&gt;
          &lt;activity android:name="FileUploader"
                    android:label="..."
                    &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.SEND"/&gt;
                  &lt;data android:mimeType="*/*"/&gt;
                  &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
      &lt;service android:name=".FileUploaderService" /&gt;
  
  
      &lt;/application&gt;
  </code></pre>
  
  <p>FileUploader is an activity which should be launched from other activities (eg. Gallery or Camera).
  FileUploaderService is a service, which actually uploads file to HTTP server. It executes several HTTP requests.</p>
  
  <p>Now it is possible that user press Home button during uploading and returns to Home screen.
  In this case I want to have a notification with current upload stage details which will return user to Activity when tapped.</p>
  
  <p>I'm creatung it like this:</p>
  
  <pre><code>    int icon = R.drawable.icon;
      CharSequence tickerText = "Uploading File";
      long when = System.currentTimeMillis();
  
      Notification notification = new Notification(icon, tickerText, when);
  
      Context context = getApplicationContext();
      CharSequence contentTitle = "Uploading File";
      CharSequence contentText = "Upload in progress. Stage #" + i;
  
      Intent notificationIntent = new Intent(this, FileUploader.class);
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
              notificationIntent, 0);
  
      notification.flags |= Notification.FLAG_AUTO_CANCEL;
      notification.setLatestEventInfo(context, contentTitle, contentText,
              contentIntent);
  
      mNM.notify(R.layout.main, notification);
  </code></pre>
  
  <p>The problem is that when I press home button during upload - FileUploader activity instance which was launched from Gallery becomes "stopped" and when I tap notification - 2nd FileUploader activity instance is launched.</p>
  
  <p>So is it any way to "return" to the first activity when tapping notification instead of launch new one?</p>
  
  <p>I've tried following ways but non of them work here:</p>
  
  <ol>
  <li><p>call finish() in FileUploader.onStop() method - activity is closed when switching from portrait to landscape.</p></li>
  <li><p>set android:launchMode="singleTask" for FileUploader activity in AndroidManifest.xml - after this my applcation starts to appear in Recent Applications list, which is not acceptable since it allows to launch FileUploader activity from there and as I mentioned above it only should be launched by sending android.intent.action.SEND intent from Gallery/Camera.</p></li>
  <li><p>Use same intent as was used to launch 1st instance - 2nd instance still created and following warning is in logs:</p>
  
  <p>04-12 17:01:17.041: WARN/ActivityManager(1289): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.SEND typ=image/jpeg cmp=.FileUploader bnds=[0,628][480,723] (has extras) }</p></li>
  </ol>
  
  <p>I've also tried to change line:</p>
  
  <pre><code>    Context context = getApplicationContext();
  </code></pre>
  
  <p>with</p>
  
  <pre><code>    Context context = this; // FileUploadServiceContext
  </code></pre>
  
  <p>But this doesn't help.</p>
  
  <p>Hmmm. I thought, maybe I launch wrong activity. Probably I should launch "parent" activity for my FileUploader.
  For example: if I launch FileUploader from Gallery, then tap Home, then launch Gallery from Home screen again - I return to my Activity. So I wonder, maybe I need to launch Gallery/Camera from notification. But 2 questions:</p>
  
  <ol>
  <li><p>how to determine what exactly was the parent of my activity?</p></li>
  <li><p>what to do if that parent was closed by the system?</p></li>
  </ol>