NFC broadcastreceiver problem
===

I want my app to listen to nfc tags only when is activated. For this I tried to register an nfc listener as following, without any success. 
	
	IntentFilter filter = new IntentFilter("android.nfc.action.TECH_DISCOVERED"); 
	registerReceiver(nfcTagListener, filter); 

	BroadcastReceiver nfcTagListener = new BroadcastReceiver() {

			@Override
			public void onReceive(Context context, Intent intent) { 
				String action = intent.getAction(); 

				if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { 
					Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);	
					Log.d("nfc", "" + tag.getId()); 	
				}
			}
		};

		
I tried as well to declare the intent in my manifest following the apidemos and works perfectly, it launches my activity and gets the nfc tag id. But this is not what I want, I want to detect the tag id only when I am inside that activity. I am thinking it might be related to the following line included in the api demos. But I dont know how to do that programatically 

          <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
                android:resource="@xml/filter_nfc"> 

Any hint? 

Thanks! 

