use FLAG_ACTIVITY_SINGLE_TOP
then override onNewIntent() to get the new intent. Android is
determined that getIntent() always get the original intent, so cache
the new intent in onNewIntent(), then check for it in onResume().
works for me.
hth
>I have a problem with starting an intent from a BroadcastReceiver,
>where everytime onReceive() is called from the BroadcastReceiver it
>starts an intent which loads an activity. My problem is every time it
>seems to start a new instance of the Acitivty (even if it is already
>running) and I would like it to be a singleton. The problem this
>causes is that after a few calls of onReceive(), if the user hits the
>back button on the app, they are presented with what sees to be the
>same activity multiple times.
>
>Here is the basics of what I am doing:
>
>public class MyReceiver extends BroadcastReceiver
>{
>
> @Override
> public void onReceive(Context context, Intent intent)
> {
> try
> {
>
> Intent iAlarm = new Intent( context,
>MyActivity.class );
> iAlarm.addFlags(Intent.FLAG_FROM_BACKGROUND);
> iAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> context.startActivity(iAlarm);
> }
> catch( Exception e )
> {
> .....
> }
> }
>
>}
>
>
>Any pointers would be appreciated, and thanks for your help in
>advance.
>
>Thanks,
>Chuck
>
>--
>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
--
jason.vp.engineering.particle
--
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