Hello, i have a problem after Read / Write my NFC Tags.
Runtime Error
API cannot be called while activity is paused
End Application
It's really annoying.
I scan my NFC Tag and piep-sound comes.
I must select my App for NFC action and then this error.
(EDIT: The Tag is read or writen but the error message is there and its stupid look)
Please can anyone tell me how can i delete this error?
I’m not sure what the most current version of your blocks are, but it is possible for TagRead to be executed even if the activity isn’t in the resumed state as it’s triggered from within a BroadcastReceiver. The write mechanism for NFC checks to see if the activity is running and throws the error you see if not (android source).
There are newer APIs to accomplish what the NFC component does that are more robust to the activity lifecycle. It’s possible that we could adapt the component to use those in the future.
There are newer APIs to accomplish what the NFC component does that are more robust to the activity lifecycle. It’s possible that we could adapt the component to use those in the future.
Not that it helps, but Google has deprecated most of the NFC API starting with Android Q. So depending on what you’re trying to do you may want to look for an alternative solution as it may not be around in a few years.
Hi all,
I have the same issue “api cannot be called while activity is paused”. I tried to read everything but did not understand if any solution has been found.
Is there any solution, to remove the error?
I tried with the apk and not the live companion: issue is still there
ball cup app works without error.
with any other apps downloaded from playstore, everything works well, no error.
This means Google no longer supports the NFC API and does not intend to upgrade it. Evan suggests that you find a different solution that using the NFC API.
There is not a solution to “api cannot be called while activity is paused”. There might never be a solution because Google has deprecated the NFC API. In the world of software development, " deprecated " refers to functions or elements that are in the process of being replaced by newer ones. ... so the 'old' methods no longer work Fabio.
Dear Steve,
thank you for your reply. I think I have somehow, I don’t know exactly how, solved the problem. it does not appear anymore…
i have a new couple of questions, if I am allowed to.
As far as I understood, you told me that nfc api will, in the future, not be anymore available. Does this mean that it will be impossible to read nfc tags in the future with any app (made with app inventor), or it will be necessary to do it in some oher way? I don’t know if I understood correctly.
If there will be another way to read and write nfc tag, which will be this way?
Sorry, I forgot to tell you that I am not at all an expert of coding and app making, this is my first try ever. I am not probably aware of what is exactly API and if there are alternatives to it when using app inventor.
Thank you, and thank you for your patience
Google has deprecated many of the NFC API functions used by the NFC component according to MIT. That means that sooner or later parts of the component will not be usable. When? Maybe next month, maybe next year. What happens depends on what Google decides to do and whether MIT will upgrade the NFC tool it provides. Evan says “developers may want to look for an alternative solution as it (the NFC) may not be around in a few years”. He is speculating; he does not know for sure.
Will there be another way to read and write nfc tag? I do not know . You might read these articles.
Evan indicates that some (but perhaps not all) of the capabilities of the NFC component might have issues as Google deprecates the api.