In your Application class add the following line to initialize DyScan.
public class DyScanApplication extends Application {
//...
@Override
public void onCreate() {
super.onCreate();
//...
DyScan.init(this, "{YOUR_API_KEY}");
//...
}
}
Check if the device supports NFC scanning
You can use the method DyScan.hasNfcFeature() to confirm that the device your app is running on is able to scan cards using NFC. It will return true if the device is supported and dynetiNFC has loaded. It will return false if the device is not supported or the NFC SDK could not be found.
Enable and Disable NFC scanning in your activity
In the activity you would like to perform the scan, enable the scanner during your onResume method and disable the scanner in your onPause method.
override fun onResume() {
super.onResume()
if (DyScan.hasNfcFeature()) {
DyScan.dynetiNFC.enableScanning(this);
}
}
override fun onPause() {
if (DyScan.hasNfcFeature()) {
DyScan.dynetiNFC.disableScanning(this);
}
super.onPause()
}
Read the result of the NFC Scan
In your activity, listen for the result intent using the onNewIntent method: