You need to enableForegroundDispatch() on every activity that is supposed to be watching for NFC tag events. From what I've read, if Activity A enables dispatch and Activity B is in the foreground, the dispatch doesn't happen.
Also, to get onNewIntent() to work, make sure your Intent inside the PendingIntent has FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP as its flags. Here is a sample application demonstrating this: https://github.com/commonsguy/cw-advandroid/tree/master/NFC/URLTagger On Tue, Jun 14, 2011 at 5:52 AM, Ferit T <[email protected]> wrote: > Hi, > > i'm a relatively new to the android development so there could be some > dummy question. Sry for that. > > My problem is that i have an android application with 3 different > activities; first activity is more like a container, one activity is > responsible for some browsing and the third one has more application > logic. What i want to do is, to enable some simple NFC functionality. > Currently if the application is created the tag is read i got the > information about it and i can display it. > > The problem is, if i want to activate foreground dispatch for this > application the onNewIntent() method is not invoked. What i got in > DDMS : > > 06-14 11:36:56.125: INFO/NfcService(209): Dispatching to override > intent PendingIntent{40591da0: android.os.BinderProxy@405604d8} > 06-14 11:36:56.132: INFO/ActivityManager(109): Starting: Intent > { act=android.nfc.action.NDEF_DISCOVERED dat=http://www.ttag.be/m/ > 04598EBA342380 flg=0x30000000 cmp=de.fhg.fokus.fame.mwr2.android/ > de.fhg.fokus.fame.android.nfc.NfcManagerImpl (has extras) } from pid > -1 > > The application is still in foreground and everything looks fine, but > i thought that there is some problem with the right allocation of the > PendingIntent Filter. > > Is there any specification with the foreground dispatch system? > Perhaps if the 2ndActivity is in foreground and the 3rdActivity is > called from the 2ndActivity both are used at the same time and there > could be some difficulty with the declaration of my PendingIntent. > > My first intention is that it has something to do with the registered > PendingIntent. Anybody some suggestions? Or what especially > PendingIntents do? > > kd, > > Ferit Topcu > > -- > 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 > -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://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

