It should be noted that there is a spelling mistake in the code
version, this is how it should read:
IntentFilter mFilter = new IntentFilter
("android.intent.action.DATA_SMS_RECEIVED");
I typed it up in a browser and made the mistake.Thanks. On Mar 30, 11:24 am, thesquib <[email protected]> wrote: > I have created a broadcast receiver statically by specifying it within > the Manifest, and I have also created the "same" broadcast receiver in > code and have registered it with the application context. The static > way works very well, but the dynamic way does not receive the expected > broadcast. It could be that I am not creating the intent filter > correctly, or that I need to register it with some other context > somewhere. Please see the code examples to see what I am doing. This > is related to receivingdataSMS, it works very well on a device using > a broadcast receiver defined in the Manifest. The correct permissions > are set for both examples. > > The following is from the Manifest, and the resulting receiver gets > the expected broadcasts: > <receiver android:name=".MyReceiver"> > <intent-filter> > <action android:name="android.intent.action.DATA_SMS_RECEIVED" /> > <dataandroid:scheme="sms" android:host="localhost" > android:port="6432"/> > </intent-filter> > </receiver> > > The following is the code example that doesn't work (it does work with > an intent like "android.provider.Telephony.SMS_RECEIVED" but not fordatasms): > MyReceiver mReceiver = new MyReceiver(); > IntentFilter mFilter = new IntentFilter > ("android.intent.action.DATA_SMS_RECEIVER"); //also tried an empty > filter > intentFilter.addDataAuthority("localhost", "6432"); > intentFilter.addDataScheme("sms"); > context.registerReceiver(mReceiver, mFilter); > > The question is - why does this broadcast receiver get notified of the > incomingdatamessages? It seems some other resource is notified when > the Manifest version of the receiver is created... > > Thank you, > Squib --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

