मेरे पास एक कक्षा है, जो एनएफसी और दो सक्रियताओं के लिए संयोजन बनाती है। उनमें से दोनों उस वर्ग का एक वस्तु बनाते हैं ताकि वे एनएफसी से जुड़ सकें। इससे पहले कि यह किसी भी तरह से काम करता था लेकिन अब मुझे समस्या है - मेरा आवेदन पहले गतिविधि पर भी, न्यूइन्टेंट पर कुछ भी नहीं करता है। इसके बजाय, मैं "टैग" (नेक्सस एस) नामक बिल्ड-इन ऐप से "नया टैग एकत्रित" देख सकता हूं।आवेदन के टैग पढ़ने के बजाय "नया टैग एकत्रित" - एनएफसी एंड्रॉइड
मुझे क्या करना चाहिए?
वर्ग:
public NFCForegroundUtil(Activity activity)
{
super();
this.activity = activity;
mAdapter = NfcAdapter.getDefaultAdapter(activity
.getApplicationContext());
mPendingIntent = PendingIntent.getActivity(activity, 0, new Intent(
activity, activity.getClass())
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
IntentFilter ndef2 = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
IntentFilter ndef3 = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
try
{
ndef2.addDataType("*/*");
}
catch (MalformedMimeTypeException e)
{
throw new RuntimeException("fail", e);
}
mFilters = new IntentFilter[] {ndef, ndef2, ndef3 };
mTechLists = new String[][] { new String[] {
// android.nfc.tech.NfcV.class.getName(),
android.nfc.tech.NfcA.class.getName(),
android.nfc.tech.IsoDep.class.getName() } };
mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters, mTechLists);
}
गतिविधि 1:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
nfcForegroundUtil = new NFCForegroundUtil(this);
}
@Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
Intent i = new Intent(this, NfcDisplayLabelActivity2.class);
startActivity(i);
}
ठीक है, आपने इसे ठीक से कैसे काम किया? –
यदि आपको अभी भी समस्याएं हैं, तो मेरा जवाब देखें। – MagicSeth
इस उत्तर में वास्तव में कोई उपयोगी डेटा नहीं है। बस "ओह, मैंने अपना ऐप सही किया और अब यह काम करता है" समुदाय को कुछ भी नहीं बताता है कि _how_ ऐप को सही किया गया था और _what_ आप शुरू में गलत तरीके से कर रहे थे। – jwir3