Android Question [SOLVED] Unexpected event (missing RaiseSynchronousEvents): txtsfilter_textchanged

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,
this error was already mentioned in this forum, but I didn't find any solution for me.
I need use debug mode, so that isn't good for me, that 'in release mode there is no error'
I use b4a 9.80, and this error happen in emulator and real device too, as Erel said because in debug mode the engine runs in pc.
THIS ERROR HAPPEN ONLY IF MY EDITTEXT FIELD IS B4XVIEW!!
So why happen error, if I have the textchanged sub?
B4X:
...
Private txtsfilter As B4XView
...
Sub txtsfilter_textchanged (Old As String, New As String)
    'If New.Length = 1 Or txtsfilter.Text.Length = 2 Or Old.Length = 2 Then Return
    CLVItemList.sv.Visible = False  'Added because of the divider line flashing its full background color
'    Wait For (FilterSearch(New)) Complete (Completed As Boolean)
'    CLVItemList.sv.Visible = True
    FilterSearch(New)
End Sub
B4X:
Unexpected event (missing RaiseSynchronousEvents): txtsfilter_textchanged
Check the unfiltered logs for the full stack trace.
Error occurred on line: 72 (TorzsekPartnerLista)
java.lang.NullPointerException
    at com.lszamla.torzsekpartnerlista._txtsfilter_textchanged(torzsekpartnerlista.java:753)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at anywheresoftware.b4a.shell.Shell$2.run(Shell.java:321)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5323)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
    at dalvik.system.NativeStart.main(Native Method)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I need use debug mode, so that isn't good for me, that 'in release mode there is no error'
This is never the answer. The answer is that this message is a warning related to the debugger. The code should still work in debug mode, however the behavior of the event will not be exactly the same as in release mode.

Why aren't you using SearchView or MiniSearchView or B4XSearchTemplate?
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Thanks for reply Erel. I choose this solution because I have not a simple list, but a more complex data list to select from.
But the mentioned message (Unexpected event (missing RaiseSynchronousEvents): txtsfilter_textchanged) not a warning, but a real error, my program exit immediately, if I use b4xview, but not exit if I use edittext.
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
This is the project. Error happens when you press buttons items -> items -> new item and here in debug mode the program exits, in release mode doesn't.
If I change
B4X:
Private txtsfilter As B4XView
to edittext, then will be good also in debug mode.
 

Attachments

  • LSZAMLA.zip
    21.8 KB · Views: 191
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see why it happens. It is a bit difficult to explain but the workaround is to cast it to EditText:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    Dim et As EditText = txtsfilter
    et.Text = ""
End Sub

It works with EditText because EditText.Text property is marked with @RaisesSynchronousEvents.
B4XView.Text isn't (currently) marked with this property and there might be performance implications to adding it to B4XView.

In most cases there is no harm that the event is not raised synchronously. In this case, because it happens in Activity_Pause, the event is raised after the activity was paused.
 
Upvote 0
Top