Android Question Inline Java Code problem

dragonguy

Active Member
Licensed User
Longtime User
java inline code is it can call the service sub?

my service module name ="service1" and code:
B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
     Private NativeMe As JavaObject
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    NativeMe.InitializeContext
End Sub

Sub Service_Start (StartingIntent As Intent)
NativeMe.RunMethod("reset",Null)
End Sub

Sub Service_Destroy

End Sub

sub test()
log("test")
end sub

#if JAVA
public void reset(){
anywheresoftware.b4a.keywords.Common.CallSubNew(mostCurrent.activityBA,service1.getObject(),"test");
}
#end  if

i got the error
B4X:
B4A version: 6.80
Parsing code.    (0.08s)
Running custom action.    (0.84s)
Running custom action.    (1.67s)
Compiling code.    (0.58s)
Compiling layouts code.    (0.05s)
Organizing libraries.    (0.00s)
Generating R file.    (2.56s)
Compiling debugger engine code.    (5.02s)
Compiling generated Java code.    Error
javac 1.8.0_66
src\com\probitto\my\fnap\callsmsservice.java:1261: error: cannot find symbol
                anywheresoftware.b4a.keywords.Common.CallSubNew(mostCurrent.activityBA,service1.getObject(),"test");
                                                                           ^
  symbol:   variable activityBA
  location: variable mostCurrent of type callsmsservice
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
 

dragonguy

Active Member
Licensed User
Longtime User
Why are you using inline Java for this?
Camera led flash, inside Java code have a loop to blinking the flash, service module need to know is it blink finish. So I decide after finish blinking then call the service sub set the status done.
 
Last edited:
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
B4X:
NativeMe.RunMethod("reset",Null)
CallSub(Me,"test")

Is it like that?
Is it callsub code will run after native code run finish?
 
Upvote 0
Top