Thank you for the explanation :)

I removed the setIntent(new Intent()) code and from your explanation I
was expecting to see the NDEF action on the intent,
since I was no longer setting an empty one.

However, when I return from the home screen I get the
android.intent.action.MAIN action, which I think makes sense.
The OS has received an 'intent' from the NFC hardware, which one of my
intent filters in the manifest matched, and then in order to launch my
application uses the 'MAIN' action?

Which is then what I receive in my onResume code.

It seems like I want the original intent that caused the app to be
launched, not the 'launching' intent.

Does that makes sense? or seem logical? :)

On Jul 20, 5:11 am, Michael Roland <mi.rol...@gmail.com> wrote:
> Hallo Kev,
>
> I wouldn't call that odd behavior but rather an exact match what you
> have written in your code.
> NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction()) will
> not return true if the intent received from getIntent() does not
> contain that action.
>
> So if your app is started for the first time by the NDEF_DISCOVERED
> intent, the condition will be true. Then you use setIntent(new
> Intent()). So the next call to getIntent() will return that new
> (empty) intent.
>
> Now you send your app into the background by pressing the home key.
> Note that the activity is still paused in background. When the app is
> triggered by a new NDEF_DISCOVERED intent, onResume() is called on the
> existing activity. Therefore, getIntent() will still return the intent
> you set with setIntent(...).
>
> br,
> Michael

-- 
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

Reply via email to