I did omit the registerRecevier() in the example but it is my code. >From the logs I am receiving onReceive is being called on a new process and my Application.onCreate() is being called where i print the Process Id and these new Process Id are all different.
My receiver is being used in my service. Thanks, On Apr 26, 8:09 am, Mark Murphy <[email protected]> wrote: > On Thu, Apr 26, 2012 at 7:53 AM, beachboy <[email protected]> wrote: > > As I understand it from a previous post and behavior I have seen in my > > application under certain instances Android will spawn a new process > > for a BroadcastReceiver onReceive. > > If a process for your app is not running, and your BroadcastReceiver > is registered via the manifest (e.g., <receiver>), Android will spawn > a new process. Otherwise, normally, Android will use your existing > process. > > > 1) If I create the BroadcastReceiver as: > > > private BroadcastReceiver mBroadcastReceiver; > > private Runnable mRunnable; > > > void xyz() { > > mBroadcastReceiver = new BroadcastReceiver() { > > @Override > > public void onReceive(Context, Intent intent) { > > mRunnable.run(); > > } > > }; > > } > > > if the onReceive is called in a new process > > It will never be called in a new process in this case. First, you > never register your BroadcastReceiver. Second, even if you did (via > registerReceiver() in your activity or service), you already have a > process. > > > can I reference objects/ > > memory in the onReceive that was associated with the object that > > created the BroadcastReceiver. In this example can i reference > > mRunnable? > > Yes, because this is not a new process, but rather your existing process. > > > 2) If the answer to question #1 is yes can I call the mRunnable.run() > > as in the example above and have a thread be run even though its in > > another process? > > It will not be in another process, as previously noted. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training in NYC:http://marakana.com/training/android/ -- 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

