Java Question java.lang.Exception: Sub datastore_onstatuschange signature does not match expected signature.

DonManfred

Expert
Licensed User
I´m getting this error when raising an event in b4a from a library.

SyncStatusListener added
ba.subExists(datastore_onstatuschange)
found.. Raising.. datastore_onstatuschange

java.lang.Exception: Sub datastore_onstatuschange signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:177)
at anywheresoftware.b4a.BA$3.run(BA.java:320)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
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:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
java.lang.Exception: Sub datastore_onstatuschange signature does not match expected signature.
B4X:
    @ShortName("DbxDatastore")
    @Events(values={"onstatuschange(ds As DbxDatastore)"})
    public static class DbxDatastoreWrapper extends AbsObjectWrapper<DbxDatastore> {
        private SyncStatusListener listener;
        private String eventName;
        public void startListening(final BA ba, String EventName) {
        //SensorManager sm = (SensorManager) ba.context.getSystemService(Context.SENSOR_SERVICE);
        eventName = EventName.toLowerCase(BA.cul);
            final String s = EventName.toLowerCase(BA.cul) + "_onstatuschange";
        listener = new SyncStatusListener() {

           @Override
            public void onDatastoreStatusChange(DbxDatastore ds){
                     //BA.Log("Event onStatusChange raised in Library");
                     BA.Log("ba.subExists("+eventName + "_onstatuschange"+")");
                   if (ba.subExists(eventName + "_onstatuschange")) {
                       BA.Log("found.. Raising.. "+eventName + "_onstatuschange");
                
                       ba.raiseEventFromDifferentThread(null, null, 0, eventName+"_onstatuschange", true, new Object[] {ds});   
                  } else {
                      BA.Log("NOTFOUND '"+eventName + "_onstatuschange");
                  }
                   //ba.raiseEventFromDifferentThread(null, null, 0, eventName + "_onDatastoreStatusChange", true, new Object[] {ds});   
                   //BA.Log("Raising: "+s);
              //ba.raiseEvent(ba, s, ds);            
            }
        };
          getObject().addSyncStatusListener(listener);
            BA.Log("SyncStatusListener added");
      }
        public void stopListening(final BA ba, String EventName) {
          getObject().removeSyncStatusListener(listener);     
            BA.Log("SyncStatusListener removed");
        }
the sub is declared in b4a-project

B4X:
Sub datastore_onstatuschange(ds As DbxDatastore)
   
End Sub
Can anybody give any hint of what i´m doing wrong here?
 

DonManfred

Expert
Licensed User
I found out that changing my sub in b4a to
B4X:
Sub datastore_onstatuschange(ds As Object)
    Dim store As DbxDatastore = ds
    Log("datastore_onstatuschange("&store.Title&")")
    Dim s As DbxDatastoreStatus = store.SyncStatus
Log(IfTrue(s.hasIncoming,"I","i")&"."&IfTrue(s.hasOutgoing,"O","o")&"."&IfTrue(s.isConnected,"C","c")&"."&IfTrue(s.isDownloading,"D","d")&"."&IfTrue(s.isUploading,"U","u")&"."&IfTrue(s.needsReset,"R","r") )
End Sub
will work. But i will have a look at your comments. Actually i do not understand what 1. means to my code and for 2. i even dont know what i´m doing wrong.
 
Top