Thursday, July 28, 2011

[android-developers] Re: how to force restart activity from intent

Just override onNewIntent().
http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)

On 26 Juli, 11:01, jjoe64 <g.jjo...@googlemail.com> wrote:
> hello.
> my MainActivity has the lauchMode="singleTask"
>
> now I want to start the activity from a notification with special intent
> data.
> in MainActivity#onResume I access the given intent data...
>
> the problem is: When the activity already exists, and I click on the
> notification, the activity comes to foreground, but the method #onResume is
> not called and I cannot access the intent data.
>
> I tried the flag FLAG_ACTIVITY_CLEAR_TASK and this works for honeycomb but
> not for gingerbread.
>
> This is how I start the activity from notification:
>
> Intent intent = new Intent();
> intent.setClass(this, MainActivity.class);
> intent.putExtra("triggerid", triggerid);
> startActivity(intent);

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment