How do you run your application? It seems like you are running always through the onCreate method which creates a new broadcast receiver instance. If you want to avoid this don't send an intent in the onCreate.
-- Roman Baumgaertner Sr. SW Engineer-OSDC ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Aug 17, 10:28 am, R Ravichandran <ravirajami...@gmail.com> wrote: > Hello, > > I have an application that uses an extended BroadcastReceiver class inside > the Activity. I have the extended BroadcastReceiver class as a member > variable of the Activity class. But it looks like the receiver references > keep changing between its construction and 'onReceive' method call. I would > like to understand this better. Here are some details. > > public class MyEventReceiver extends BroadcastReceiver { > > public MyEventReceiver(BNDialogInterface dlg) { > System.out.println("Receiver Object in constructor: "+this); > } > > public void onReceive(Context context, Intent intent) { > System.out.println("Receiver Object in onReceive: "+this); > } > > } > > My Activity class: > > public class Notepadv2 extends Activity { > private MyEventReceiver receiver; > > protected void onStart() { > // TODO Auto-generated method stub > super.onStart(); > receiver = new MyEventReceiver(this); > > Intent myIntent = new Intent("Test"); > sendBroadcast(myIntent); > } > > } > > <?xml version="1.0" encoding="utf-8"?> > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.android.demo.notepad2"> > <application android:icon="@drawable/icon"> > > <receiver android:name=".MyEventReceiver" android:enabled="true" > android:exported="true"> > <intent-filter> > <action android:name="Test" /> > </intent-filter> > </receiver> > > <activity android:name=".Notepadv2" > android:label="@string/app_name"> > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > > <activity android:name=".NoteEdit"></activity> > </application> > </manifest> --~--~---------~--~----~------------~-------~--~----~ 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-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---