diff --git a/README.md b/README.md index ed2b519..9687c3b 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,7 @@ class MainActivity : FlutterActivity() { } override fun onNewIntent(intent: Intent) { - val tag: Tag? = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) - if (tag != null) { - FlutterNfcKitPlugin.handleTag(tag) - } + intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)?.apply(FlutterNfcKitPlugin::handleTag) } } ``` diff --git a/example/android/app/src/main/kotlin/im/nfc/flutter_nfc_kit/example/MainActivity.kt b/example/android/app/src/main/kotlin/im/nfc/flutter_nfc_kit/example/MainActivity.kt index 453bf47..fcb1078 100644 --- a/example/android/app/src/main/kotlin/im/nfc/flutter_nfc_kit/example/MainActivity.kt +++ b/example/android/app/src/main/kotlin/im/nfc/flutter_nfc_kit/example/MainActivity.kt @@ -14,6 +14,7 @@ class MainActivity : FlutterActivity() { val pendingIntent: PendingIntent = PendingIntent.getActivity( this, 0, Intent(this, javaClass).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_MUTABLE ) + // Read the docs for reading specific technologies adapter?.enableForegroundDispatch(this, pendingIntent, null, null) } @@ -24,7 +25,6 @@ class MainActivity : FlutterActivity() { } override fun onNewIntent(intent: Intent) { - val tag: Tag? = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) - FlutterNfcKitPlugin.handleTag(tag!!) + intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)?.apply(FlutterNfcKitPlugin::handleTag) } }