I dont think you can use NFC witout an intent. If NFC is switched off the it wont read cards (obviously) but when on it only works with an intent.
yes, thank you Joham
now i got it to work.
but maybe because my app is very complex (many views etc not just one) i manage to read several times perfectly and then with no reason the app crashed with this error message in the log
this error also happens with your sample app
after that nothing will make it work only reset to the phone sometimes multiple times
any ideas?
there are 2 errors each from a different device
this is from a phone with android 9
---------------------------------------
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.github.tapcard.emvnfccard.model.EmvCard.getCardNumber()' on a null object reference
at tapcardwrapper.tapcardWrapper.showCardInfo(tapcardWrapper.java:137)
at tapcardwrapper.tapcardWrapper.access$100(tapcardWrapper.java:68)
at tapcardwrapper.tapcardWrapper$1.onPostExecute(tapcardWrapper.java:171)
at tapcardwrapper.tapcardWrapper$1.onPostExecute(tapcardWrapper.java:153)
at android.os.AsyncTask.finish(AsyncTask.java:696)
at android.os.AsyncTask.access$600(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:713)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
this is from a phone with android 13 (the app crashes upon running and does not even start)
it happens here:
tapcard.Initialize("ips")
-------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: arkom.webeft.android: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:408)
at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:491)
at android.app.PendingIntent.getActivity(PendingIntent.java:477)
at android.app.PendingIntent.getActivity(PendingIntent.java:441)
at io.github.tapcard.android.NFCUtils.<init>(NFCUtils.java:87)
at io.github.tapcard.android.NFCCardReader.<init>(NFCCardReader.java:32)
at tapcardwrapper.tapcardWrapper.Initialize(tapcardWrapper.java:83)
at arkom.webeft.android.main._activity_create(main.java:1017)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at arkom.webeft.android.main.afterFirstLayout(main.java:105)
at arkom.webeft.android.main.access$000(main.java:17)
at arkom.webeft.android.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8741)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)