2012-04-04 35 views

回答

3

如果包括這在你的清單您的應用程序將只能在具有NFC設備上運行:

<uses-feature android:name="android.hardware.nfc" android:required="true" /> 

NfcAdapter.getDefaultAdapter(this)也可以具有NFC的設備上返回null,但NFC功能不可用出於某種原因在這種情況下。

1

如果您將其上傳到Play商店,那麼您可以選擇哪些設備可以下載該應用程序,因此請牢記這一點。

這是如何檢查設備是否可以使用NFC。

NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); 
     if (mNfcAdapter == null) { 
      Toast.makeText(this,"NFC is not available on this device.", LENGTH_LONG).show(); 
     } 
+0

ya謝謝....但有沒有其他的選擇,通過在manifest.xml本身給予條件?... – Siva 2012-04-04 09:37:44

0

這包括到您的AndroidManifest.xml:

<uses-feature android:name="android.hardware.nfc" /> 

這樣做,應用程序將只提供下載到能夠使用NFC功能的設備。

關於這方面的更多信息可以在here找到。

+0

如果我們給這樣的意思,應用程序將運行即使在NFC不可用設備.... – Siva 2012-04-04 09:38:43

+0

是的,但不提供給Play商店的用戶。這取決於您的分銷策略,如果這對您而言是足夠的。這個標籤只是一個語義標籤,表明您的應用程序使用NFC。 – Matthew 2012-04-04 13:24:04