Android Question CCTV Server after ScreenOn

Andrew A Gray

Member
Licensed User
One last issue with the CCTV Server program. When I put the Android "to sleep" (screen turned off), CCTV Server seems OK while screen is off. But when ScreenOn happens, the app crashes on this statement:

B4X:
size = r.RunMethod("getPreviewSize")

And this is the log:

B4X:
** Activity (main) Resume **
findCamera
null
2
facing: 0, 0
Error occurred on line: 259 (CameraExClass)
java.lang.NoSuchMethodException: getPreviewSize []
   at java.lang.Class.getMethod(Class.java:630)
   at java.lang.Class.getDeclaredMethod(Class.java:589)
   at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
   at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
   at b4a.example.cameraexclass._previewimagetojpeg(cameraexclass.java:106)
   at b4a.example.main._camera1_preview(main.java:452)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
   at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1051)
   at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:993)
   at b4a.example.cameraexclass._camera_preview(cameraexclass.java:358)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
   at anywheresoftware.b4a.objects.CameraW$2$1$1.onPreviewFrame(CameraW.java:147)
   at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1183)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:7325)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Does your CCTV Server do the same? What needs to be done to fix this?
 
Last edited:

Andrew A Gray

Member
Licensed User
Yes, I went back to the original MJPEG_CCTV.zip file and it had the same ScreenOn crash.
So I tried a few things. Putting a Sleep in the resume Sub seemed to fix it.
B4X:
Sub Activity_Resume
   Sleep(2000)
   InitializeCamera
   UpdateUI
End Sub

Thanks again for your help!
 
Upvote 0
Top