Thank you Mark - this was never very clear in any of the books I've bought
regarding Android programming or on Android website unfortunately.

My next question is as follows:

I've listed a receiver in the manifest as suggested pointing to the
following definition:

public class TESTWAKEUP extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
           Intent rerun=new Intent(context,MyApp.class);
           rerun.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
           rerun.putExtra("fromstaticreceiver", "parameter");
           context.startActivity(rerun);
        }
  }
   }

Now, for some reason, when my activity is brought back to the foreground by
the about receiver (which is triggered by a Service), it does not seem that
the extra parameter is ever receiver:

@Override
public void onCreate(Bundle savedInstanceState) //this is for MyApp
{
Intent argv=getIntent();
Bundle bundle = argv.getExtras();
String fromstaticreceiver=null;
if (bundle != null)
fromstaticreceiver = bundle.getString("fromstaticreceiver");
                Log.d("here:", "fromstaticreceiver=" + fromstaticreceiver);
//always shows null for fromstaticreceiver

My question is:does getIntent() represent the argument of the intent that
originally started the activity or does it reflect intent in the system
that are forcing an activity to come to the foreground?

Many thanks for any feedback on this front.

Rdgs,


On Wed, Aug 15, 2012 at 9:43 AM, Mark Murphy <[email protected]>wrote:

> On Wed, Aug 15, 2012 at 12:34 PM, frantz lohier <[email protected]> wrote:
> > Question: is there a way to ensure that receiver are programmatically
> > registered at run-time are not deallocated when an app goes in
> background?
>
> IMHO, a better implementation would be to register the receiver in the
> manifest, then use PackageManager and setComponentEnabledSetting() to
> control when it should and should not receive broadcasts. IMHO, a
> receiver registered via registerReceiver() from an activity should
> only be used for broadcasts while the activity is in the foreground.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 4.0 Available!
>
> --
> 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

Reply via email to