بعد تثبيت Android 2.3.4 على Nexus S، لا تبدأ تطبيقات NFC بعد الآن

StackOverflow https://stackoverflow.com/questions/6049635

  •  15-11-2019
  •  | 
  •  

سؤال

بعد تثبيت Android 2.3.4 على بلدي Nexus S، لا تبدأ تطبيقات NFC بعد الآن.

لقد حاولت مع النوايا الثلاثة (ndef_discovered، tech_discovered، tag_discovered) الموصوفة في وثائق Google، ولكن أي منها يحل المشكلة، ويستمر Nexux S في فتح تطبيقات Google الافتراضية وتجاهل تطبيقي.

كان لي هذا في البيان giveacodicetagpre.

وإذا لم أكن مخطئا، يبدو أنه مدعوم في الأخبار 2.3.3، لماذا يتجاهل نيكزس؟

هل يمكنك مساعدتي من فضلك.

مع أطيب التحيات، هوغو.

هل كانت مفيدة؟

المحلول

You need to add this to your intent filters:

<intent-filter>
   <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
</intent-filter>

When a tag is scanned, Android should show a popup asking which app to handle it.

Update

Based on additional info from your comment, the problem is that your tag contains information which is recognized by Android. In this case, that is a URL. Since Android can find an app (the default NFC app) which can handle urls, then that app will take priority and be called instead of an app which simple handles tag discovery. Tag discovery is only dispatched if no other intent filter matched the tag. To quote the docs:

android.nfc.action.TAG_DISCOVERED: This intent starts if no Activities handle the NDEF_DISCOVERED and TECH_DISCOVERED intents or if the tag that is scanned is unknown.

So you must declare your tag to handle messages in the tags as well. You need to specify exactly the type of data you are targeting as well (in this case, urls), else the Google Android app will still take precedence for URLs. You can read more information on the Android NFC page

نصائح أخرى

You have to also add data in the intent filter. Please refer to http://developer.android.com/guide/topics/nfc/nfc.html#tech-disc

and look under ACTION_NDEF_DISCOVERED in Filtering for NFC intents.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top