Closed briouyaasmae closed 2 years ago
Hey, thanks for the report, do you have steps to reproduce this please ?
I'm using those functions and I'm calling them in initstate
When I login for the first time and listen to otp, everything works well, but if I logout and login for the second time, the app crashes and this error is shown.
Maybe that's because you listen to the code but actually never unregister it? Does it work better by adding:
@override
void dispose() {
SmsAutoFill().unregisterListener();
super.dispose();
}
I'll make more test on my side see if I can reproduce it too
When I'm using SmsAutoFill().unregisterListener()
ok very weird, so far I can't reproduce. Even don't see how the receiver can't be registered...
Basically I create it like this:
unregisterReceiver();// unregister existing receiver
broadcastReceiver = new SmsBroadcastReceiver(new WeakReference<>(SmsAutoFillPlugin.this));
activity.registerReceiver(broadcastReceiver, new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION));
So when it's created; it's registered. Then to unregister I do it only when it is not created.
private void unregisterReceiver() {
if (broadcastReceiver != null) {
activity.unregisterReceiver(broadcastReceiver);
broadcastReceiver = null;
}
}
It blow my mind :D I'll keep searching that! Thanks for the details
So I have added a try/catch for now to avoid crash. As I can't reproduce of find what could go wrong... So should be good on 2.1.1. Let me know if there is any other issue.
So I have added a try/catch for now to avoid crash. As I can't reproduce of find what could go wrong... So should be good on 2.1.1. Let me know if there is any other issue.
So this issue is still there try catch just to prevent app crashes. I am facing an issue that after 5 minutes which is timeout i have to relisten by calling listenForCode again but sometimes after relisten in onReceive status.getStatusCode() still 15(timeout)
After using version 2.1.0 I get this issue E/AndroidRuntime(30428): java.lang.IllegalArgumentException: Receiver not registered: com.jaumard.smsautofill.SmsAutoFillPlugin$SmsBroadcastReceiver@ca372f0 and app crash