Android Question Calling an Event Sub with 3 variable in the same activity

Marvel

Active Member
Licensed User
I have an event sub from a library that I want to call on Activity resume. I found a thread that suggested type should be used for the variables but I keep getting a signature mismatch error.
The main purpose of this is to be able to use a timer to keep the data refreshed.

java.lang.Exception: Sub monitor_getusagedata signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject test.appusage.main_subs_0._monitor_getusagedata(anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception

class anywheresoftware.b4a.pc.RemoteObject, class java.lang.Long, class java.lang.Integer,

This is a sample of my code:

B4X:
Type Usage (UsageData As List,TotalUsage As Long,Duration As Int)

Sub Activity_Resume
    Monitor_GetUsageData
End Sub

Sub    Monitor_GetUsageData (v1 As Usage)
    ...do something
End Sub

The variables declared for the type "usage" works when used directly in front of the Sub. The problems arises when I try to parse them in with a type
 

stevel05

Expert
Licensed User
Longtime User
B4X:
Sub    Monitor_GetUsageData (v1 As Usage)

Requires a parameter which you are not providing.
 
Upvote 0

Marvel

Active Member
Licensed User
It works when I use it directly like this:
B4X:
Sub    Monitor_GetUsageData (UsageData As List, TotalUsage A Long, Duration As Int)
    ...do something
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If the event sub is called from a library that you haven't created then you can't change the signature. The call from the library will be expecting the original signature.

Also when you call the sub from within Activity_Resume you need to pass appropriate parameters.
 
Upvote 0
Top