Sunday, July 18, 2010

[android-developers] Re: Issue with starting two instances of an activity with flag Intent.FLAG_ACTIVITY_REORDER_TO_FRONT and a new extra information in the Intent does not override the original Intent.

I'm not sure if this will work or not in your situation or if you are
already doing this, but you could try this:

Implement the callback method 'onNewIntent(Intent newIntent)' in your
class 'A'.
Then when the oNewINtent is called, be sure to call
'setIntent(newIntent)'.

The thing here is, that your re-use an instance of your activity 'A'.
In this case, the activity's 'onCreate' is not called. Instead, its
'onNewIntent' is called.

On Jul 18, 5:59 am, Agus <agus.sant...@gmail.com> wrote:
> Hi all,
>
> When starting two activities of the same class within the same
> instance using the flag REORDER_TO_FRONT, the new extra information of
> the second call does not override the first starting activity. Is this
> the desired behavior? How do retrieve the new extras?
>
> For example:
> In the StubActivity, I have this code: Intent i = new Intent(this,
> A.class); i.putExtra("foobar",1); startActivity(i);
>
> Activity A is displayed, and then this code is called upon a button
> press: new Intent(this, A.class); i.putExtra("foobar",2);
> i.setFlag(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(i);
>
> Activity A is re-displayed. Now check for the extras:  int foobar =
> getIntent().getExtras().getInt("foobar")
>
> Turns out that foobar = 1

--
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