ion was not declared, so I declared it as an object (Dim ion as Object) in Process_Globals. This allowed it to compile, but when attempting to run it, I received this:
(The line is "Return jo.RunMethod("getBA", Null)" - it's not line 95 below as given because I removed the top two region definitions.)
Error occurred on line: 95 (Main)
java.lang.RuntimeException: Method: getBA not found in: org.techteam.itsyours.main
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:366)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at org.techteam.itsyours.main._getba(main.java:468)
at org.techteam.itsyours.main._startactivityforresult(main.java:552)
at org.techteam.itsyours.main$ResumableSub_RecordAudio_Click.resume(main.java:516)
at org.techteam.itsyours.main._recordaudio_click(main.java:478)
at java.lang.reflect.Method.invoke(Native Method)
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 java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$1.run(BA.java:335)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
I changed
Return jo.RunMethod("getBA", Null)
to
Return jo.RunMethod("GetBA", Null)
but that didn't seem to make any difference.
Here is my code (minus the starter service and accompanying FileProvider class):
Sub Process_Globals
Dim audioRecorder As AudioRecordApp
Dim videoRecorder As VideoRecordApp
Dim MP As MediaPlayer
Dim ion As Object
End Sub
Sub Globals
Dim vv As VideoView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
audioRecorder.Initialize("audioRecorder")
videoRecorder.Initialize("videoRecorder")
End If
vv.Initialize("vv")
Activity.AddView(vv, 0, 0, 100%x, 100%y)
Activity.AddMenuItem("Record Video", "RecordVideo")
Activity.AddMenuItem("Record Audio", "RecordAudio")
ToastMessageShow("Press on Menu button...", True)
End Sub
Sub RecordVideo_Click
Dim folder As String = Starter.Provider.SharedFolder
Dim FileName As String = "1.mp4"
videoRecorder.Record3(folder, FileName, -1, Starter.Provider.GetFileUri(FileName))
End Sub
Sub videoRecorder_RecordComplete (Success As Boolean)
Log(Success)
If Success Then
MP.Initialize2("MP")
MP.Load(Starter.Provider.SharedFolder, "1.mp4")
MP.Play
'vv.LoadVideo(File.DirRootExternal, Starter.Provider.GetFileUri("1.mp4"))
'vv.Play
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub RecordAudio_Click
Dim in As Intent
in.Initialize("android.provider.MediaStore.RECORD_SOUND", "")
Dim pm As PackageManager
Log(pm.QueryIntentActivities(in))
StartActivityForResult(in)
Wait For ion_Event (MethodName As String, Args() As Object)
Log(MethodName)
Log(Args(0))
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject = Me
Return jo.RunMethod("getBA", Null)
End Sub