I have searched through all the documentation available on services,
and could not find anything related to this, and none of the examples
shed any light on this. After some further research and meddling with
my code I found that this does the trick inside my service:

Intent intent = new Intent(this, ExampleActivity.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, 0);

This will match the action and category set when launching the
application from the application list or desktop and therefore only
one instance is ever created.

On Jan 11, 8:33 pm, Torgny <torgny.bj...@gmail.com> wrote:
> I am trying to create a notification in a service to notify the user
> that the application's data has updated in the background. I want the
> application to resume when they click the notification. When I click
> the notification I get this message in DDMS:
>
> 01-11 16:16:10.574: WARN/ActivityManager(56): startActivity called
> from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for:
> Intent { comp={com.example/com.example.view.ExampleActivity} }
>
> This forces the activity to start even if it is already paused or
> stopped, so it never resumes, it just creates a new instance of it,
> overlapping everything, including service connections. If the
> application is already running, another copy of it starts on top of
> it. How do I make Android just resume the activity?
>
> Thankful for any help!
>
> Warm Regards,
> Torgny
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to