Hi Dianne, Thanks for this enlightening info. I finally used the android:launchMode="singleTask" option in my manifest and that solves my problem.
I will look into to the documentation of the LocalService the next days. Christophe On Mon, Dec 14, 2009 at 5:06 AM, Dianne Hackborn <[email protected]> wrote: > You can set android:launchMode to singleTop to avoid having multiple > instances of the activity created on top of each other. However, you > probably want to sit down and think about how this notification should > interact with the application in all of its states -- both while the user is > in it, and when they are elsewhere. This is probably one of most > challenging areas of Android app design, and still has some issues with even > some of the standard apps. > Anyway, there are two main approaches I would recommend taking: > (1) If your app consists of a single main activity that the user naturally > wants to return to, then have the notification intent launch that with the > standard intent (MAIN action, LAUNCHER category), with > FLAG_ACTIVITY_CLEAR_TOP so that the user will return to this instead of > whatever other activity was on top of it. The Gmail application is mostly a > good example of this, where the notification brings you to the main inbox > activity, regardless of whether you were last viewing a message. > (2) Otherwise, have the notification launch a special activity that tells > the user the full information associated with it, with facilities to launch > in to the actual application in whatever state is appropriate. This special > activity, once the user selects something in its UI, will launch the desired > regular app activity with FLAG_ACTIVITY_NEW_TASK, allowing it to be placed > on top of the app in whatever state it currently is in, or use other flags > or such to control how the user enters the current app state. The Calendar > application is a good example of this -- note how selecting its notification > brings you to a summary of all of the unhandled notifications, allowing you > to tap on one to view it in the app. > One of the goals of this is that you really want to design things so that > when the user selects your notification, they can press BACK to return to > whatever they were previously doing -- NOT to have that go back through your > app's old history stack however they last left it. > Btw, one more thing, I notice in your app manifest that you are not using > multiple processes, so you are not really doing "IPC" with the service. > This is good. In fact you don't actually need that .aidl interface at all > -- you can use the method shown in the LocalService sample code to simplify > your app a fair amount in this area: > http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/app/LocalServiceController.html > http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/app/LocalService.html > > http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/app/index.html > On Sun, Dec 13, 2009 at 8:40 AM, Christophe Vandeplas > <[email protected]> wrote: >> >> Hello, >> >> >> I'm having an issue with inter-process communication with a Service >> and Notifications >> >> >> The structure of my application is as follow: >> - ListActivity (TunnelDroid), once the user presses a listitem it will >> start a Service. >> The ListActivity is binded to the service for intra-process communication >> >> - Service (TunnelManagerService): running in the background. This >> service will add a (permanent) Notification in the statusbar. >> Using a Handler I sometimes need to communicate with the ListActivity >> (to show GUI Dialogs) >> >> - Notification: Once this notification is clicked it should open the >> ListActivity. >> >> >> To add the action when the user touches the notification I use the >> following code: >> >> notificationIntent.setClassName("net.sourceforge.tunneldroid","net.sourceforge.tunneldroid.TunnelDroid"); >> Then I use the intent to create the notification. >> >> Unfortunately a new Intent is opened. When I press the back button the >> original ListActivity is shown. >> So I have two instances of my same class/list. >> >> >> How could I make sure the original ListActivity is opened when the >> user touches the Notification? >> >> It's OK for me if the original ListActivity was previously destroyed, >> but I cannot have two instances. >> The problem is that the Handler in the Service has a reference to the >> ListActivity (PARENT_ACTIVITY), so if another instance is created I >> have invalid references. I could overwrite the PARENT_ACTIVITY, but >> then when the user presses the back button I have an instance with no >> correct link to my Service resulting in a crash/nullpointer. >> >> The complete source can be found here: >> >> http://tunneldroid.svn.sourceforge.net/viewvc/tunneldroid/tunneldroid/src/net/sourceforge/tunneldroid/ >> >> Attached you can find a drawing of (most of the) inter-process >> communication. >> >> >> Could someone point me in the right direction? >> >> >> Thanks >> >> Christophe >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

