Android NFC functionality

Asked 2 years ago, Updated 2 years ago, 42 views

I've given the NFC function to the Android Manifest file for now, so the market In the case of mobile phones without NFC function, the phenomenon of not being able to download the apk file itself occurs. For phones that do not support NFC function, how should I proceed to receive the apk file? Phones without NFC function try to read some value with QR code

nfc

2022-09-21 22:52

1 Answers

You can give android:required="false" to manifest. Adding required=false will allow you to install it even if your Android device does not have that feature.

<!--Add to manifest-->
<uses-feature
    android:name="android.hardware.nfc"
    android:required="false" />
<!--Existing NFC permissions-->    
<uses-permission
    android:name="android.permission.NFC" />

/* Java code */
NfcManager manager = 
    (NfcManager)context.getSystemService(Context.NFC_SERVICE);
NfcAdapter adapter = manager.getDefaultAdapter();

if (adapter != null && adapter.isEnabled()) {
    // Code used by nfc
} } else {
    // Code using QR code
}


2022-09-21 22:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.