I am developing an app which requires NFC. I found a way to make sure the user enables nfc if it isn't already...
public void nfcOnPressed(View view){
NfcAdapter nfc = NfcAdapter.getDefaultAdapter(view.getContext());
if (!nfc.isEnabled())
{
Toast.makeText(getApplicationContext(), "Activate NFC", Toast.LENGTH_LONG).show();
startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
} else{
Toast.makeText(getApplicationContext(), "NFC is already activated.", Toast.LENGTH_LONG).show();
}
}
Now, here is my problem: the user has to go to another page to use the nfc feature but there is no check while being on the other page if he turns it off mid-process.
An example: I open my app, enable NFC, go to the next page (before going to the next page another method checks if it is still enabled, if it isn't I can't even move on) and then, after the new page is shown, I disable it. So now I am on the new page with all the things shown I can do with NFC but you can not, since, well, I disabled it.
Is there a way to have something like a timed check if NFC is enabled? Or is there a way to check it constantly (even thought I wouldn't really want to do that).
If you need more info, just tell me what you need.
Thank you very much. :)