Hi,
I have a sub in an Activity that I need to call from other activities.
This sub involves Sql calls and web dowloads.
I need to be sure that this Sub is completed before continue.
Ive tested CallSubdelayed and it is not called when I need and CallSub seams not to work.
How can I do it?
(Forgive me Erel if I'm wrong!)
When you call a sub belonging to an activity, that activity must be the current one...
If you call a sub by "CallSubDelayed", the activity will be started, if not already;
if you call it by "CallSub", the activity should be visible, otherwise the sub wil not be called (so it is used for calling activity-subs from services or classes)
Why not considering moving your sub in a code/module or class/module ?
Im trying but and having errors.
I need a SaxParser and a Sql in the class
If I dim it in globals I get error initializing them in a sub
How to deal with it?
Sub Class_Globals
Dim SQL1 As SQL
Dim parser As SaxParser
Dim Params As Map
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
Sub wNtSyncro(pIdApp As Int,pIdw32 As Int)
parser.Initialize
SQL1.Initialize(File.DirInternal, "portit.db", True)
If Main.VersionNivel>0 And Main.NrSerieWindows<>"" And Main.IdCartera<>0 Then
ProgressDialogShow(cMessage)
.....
Calling this method using:
Dim s as ntsync
s.wNtSyncro(0,0)
I get :
ntsync_wntsyncro (java line: 569)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.SaxParser.Initialize(anywheresoftware.b4a.BA)' on a null object reference
at armi.portit.ntsync._wntsyncro(ntsync.java:569)
at armi.portit.mposicion._popupmenu_itemclicked(mposicion.java:2081)
at armi.portit.mposicion._abpop_itemclicked(mposicion.java:466)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$1.run(BA.java:325)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.SaxParser.Initialize(anywheresoftware.b4a.BA)' on a null object reference