diff --git a/src/nfc.android.ts b/src/nfc.android.ts index bf621af..1ff4bfb 100644 --- a/src/nfc.android.ts +++ b/src/nfc.android.ts @@ -421,8 +421,8 @@ export class Nfc implements NfcApi { // The adapter must be started with the foreground activity. // This allows to start it as soon as possible but only once. const foregroundActivity = application.android.foregroundActivity; - this.nfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(foregroundActivity); - if (!this.started && this.nfcAdapter !== null && foregroundActivity !== null) { + this.nfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(application.android.context); + if (!this.started && this.nfcAdapter !== null && foregroundActivity) { this.started = true; this.nfcAdapter.enableForegroundDispatch(foregroundActivity, this.pendingIntent, this.intentFilters, this.techLists); // handle any pending intent diff --git a/src/package.json b/src/package.json index 124c46b..2c0a52d 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-nfc", - "version": "4.0.3", + "version": "4.0.4", "description": "NFC plugin for your NativeScript app", "main": "nfc", "typings": "index.d.ts",