Last try - see if attached is working for "31". Have changed the Java code to be as follows:
B4X:NFCUtils(final Activity pActivity) { mActivity = pActivity; mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity); if (Build.VERSION.SDK_INT < 31) { mPendingIntent = PendingIntent.getActivity(mActivity, 0, new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); } else { mPendingIntent = PendingIntent.getActivity(mActivity, 0, new Intent(mActivity, mActivity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 67108864); } }
@agraham , please comment if I have it...
ok, tried once again to follow your replyYou don't. You call them from B4X code as 'onPause' and 'onResume'. As I said above Intellisense should show you them to choose when you type the dot after your TapCard variable name.
I've no idea about signatures - I've never used the store.
Sub ZeevTest
onPause
End Sub
I fail to understand the problem. They are methods declared in the library. Intellisense shows them. You just call them as normal.
B4X:Sub Globals 'These global variables will be redeclared each time the activity is created. Dim Card As TapCard End Sub Sub Activity_Resume Card.onResume End Sub Sub Activity_Pause (UserClosed As Boolean) Card.onPause End Sub
I don't. I program only for myself and family nowadays.
Sub Activity_Pause (UserClosed As Boolean)
'stop reads
CardReader.onPause
End Sub
oops...Ah! Johann should have made them public, not protected! They appear in the xml as available but because they are declared protected in the library they are not accessible to B4X code. If he really intended them to be available he needs to modify the library again.
public void onResume() {
nfcCardReader.enableDispatch();
}
public void onPause() {
nfcCardReader.disableDispatch();
}
thanksTry with attached library files (jar and xml). Have not tested it but the two methods should now be public (and not protected). The new lib should show as V1.03 in the B4A IDE.
B4X:public void onResume() { nfcCardReader.enableDispatch(); } public void onPause() { nfcCardReader.disableDispatch(); }
okTry with attached library files (jar and xml). Have not tested it but the two methods should now be public (and not protected). The new lib should show as V1.03 in the B4A IDE.
B4X:public void onResume() { nfcCardReader.enableDispatch(); } public void onPause() { nfcCardReader.disableDispatch(); }
If it's in your Objects/res folder it needs to be made read-only or clean project will delete it.now - why is it being deleted ?
What is line 295 in your Main activity? It looks like an unitialised List which doesn't seem to correlate with anything in the library.i get this runtime error - on both onResume & onPause
Thanks for the readonly tip...On further examination it looks like it's not within a library call at all. It looks like a B4A List.Clear command in Activity_Resume.
Which code? You not very precise I'm afraid. I'm extremely surprised if it's a call to TapCard.OnResume because that's not what the stack trace is showing.If you look at Johan's code
Try
'tgname.Clear 'clear the list that holds the tag names
'tg.Clear 'clear the list that holds the tags
'tglength.clear 'clear the list that holds the tag lengths
'tgvalue.clear 'clear the list that holds the tag values
'allow reads
CardReader.onResume 'this is line 301 that generates the error)
Catch
Log (LastException.Message)
End Try
Sub Activity_Pause (UserClosed As Boolean)
'stop reads
CardReader.onPause
End Sub
'this is to stop & restart the reading so there's no random reads
Dim CardReader As TapCard
yes!I'm getting a bit fed up with this. The stack trace above is completely different to the one you posted before. The original one was an uninitialized List and the new one is an uninitialized TapCard! My guess is that you are not being very systematic in your fault finding and are commenting stuff out at random to see what happens. That being said I suspect both have a common reason which is most likely that you hav a WaitFor in Activity_Create that is letting Activity_Resume run before you have initialized the Lists and the Tapcard.
WaitFor, as has been posted many times, returns from the Sub immediately and the Sub is re-entered at that point when the condition is satisfied. When an Activity is created B4A runs Activity_Create and then Activity_Resume. The return from a WaitFor in Activity_Create immediately runs Activity_Resume. You need to initialise the Lists and TapCard before calling WaitFor if they are referenced in Activity_Resume.i was sure that wait for waits until complete and then continues.
they are initialized in activity_create but after the wait forWaitFor, as has been posted many times, returns from the Sub immediately and the Sub is re-entered at that point when the condition is satisfied. When an Activity is created B4A runs Activity_Create and then Activity_Resume. The return from a WaitFor in Activity_Create immediately runs Activity_Resume. You need to initialise the Lists and TapCard before calling WaitFor if they are referenced in Activity_Resume.
changing order did not helpthey are initialized in activity_create but after the wait for
maybe i just need to chage the order - first to initialize then wait for ?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?