Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa9b5cae authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Update documentation to reflect the old approach not working.

The old approach has a problem with the original application's
recent tasks entry disappearing (this is probably a bug in the
platform).  Update to an alternative approach that does work.

Change-Id: I15e582eff8c77cc22628f7b099e9f04eb5bfbce7
parent 7eeaf3f0
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -245,31 +245,27 @@ an application to be part of that application's UI flow, so simply launching the
activity like this can cause it to be mixed with your normal application back stack
in undesired ways.  To make it behave correctly, in the manifest declaration
for the activity the attributes 
<code>android:launchMode="singleInstance"</code> and
<code>android:launchMode="singleTask"</code>,
<code>android:taskAffinity=""</code> and
<code>android:excludeFromRecents="true"</code>
must be set.  The full activity declaration for this sample is:</p>

{@sample development/samples/ApiDemos/AndroidManifest.xml interstitial_affinity}

<p>Because of the use of <code>singleInstance</code>, you must be careful about launching
any other activities from this one.  These activities will be launched
in their own task, and care must be taken to make sure this interacts
well with the current state of your application's task.  This is essentially
<p>You must be careful when launching other activities from this initial activity,
because this is not a top-level part of the application, does not appear in
recents, and needs to be relaunched at any point from the notification with new data
to show.  This best approach is to make sure any activity launched from it is
launched in its own task.  When doing this care must be taken to make sure this
new task interacts well with the current state of your exiting application's
task.  This is essentially
the same as switching to the main application as described for the Email style
notification shown before.  Given the <code>makeMessageIntentStack()</code>
method previously shown, handling a click here would look something like this:</p>
method previously shown, handling a click then would look something like this:</p>

{@sample development/samples/ApiDemos/src/com/example/android/apis/app/IncomingMessageInterstitial.java
  app_launch}

<p>If you don't want to use the <code>singleInstance</code> launch mode for
this activity, an alternative approach is to use <code>android:taskAffinity=""</code>.
This tells Android that the activity should not be treated as part of the
main application flow, so it will not get mixed together with that.  All of the
other issues discussed here do still apply, though this would allow you to start
additional activities that are part of this notification task instead of switching
to and replacing the main application task.</p>

<h2 id="ManageYourNotifications">Managing your Notifications</h2>

<p>The {@link android.app.NotificationManager} is a system service that manages all