Hi All,
I'm still working on my project to launch a camera after double press on power button while the device is pin locked.
Everything seems to work pretty fine but I get once every 4 times a weird exception like the one posted here after.
The camera screen is shown, the panel displays what the camera sees, but when I press on a button (example here the BtnFlash) I get an exception.
When outside the debugger, if I go on with the exception and I press power OFF + power ON to restart the camera, most often it works fine.
The camera activity (named second) is launched from a service (unlock) and just does this:
Note that I've inserted a try catch around InitializeCamera as it happens to fail too (even is less frequently) ...
Any help would be greatly appreciated !
here is the log :
LogCat connected to: B4A-Bridge: samsung GT-I9305-353575059939011
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
** Activity (main) Pause, UserClosed = true **
Installing file.
Installing file.
PackageAdded: package:test.unlock
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (unlock) Create **
** Service (unlock) Start **
** Activity (main) Pause, UserClosed = true **
** Activity (second) Create, isFirst = true **
** Activity (second) Resume **
90
[Height=720, IsInitialized=false, Width=960
]
** Activity (second) Resume **
WakeLock already held.
cameraexclass_getsupportedflashmodes (B4A line: 193)
Return r.RunMethod("getSupportedFlashModes")
java.lang.NoSuchMethodException: getSupportedFlashModes []
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getDeclaredMethod(Class.java:685)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at test.unlock.cameraexclass._getsupportedflashmodes(cameraexclass.java:568)
at test.unlock.second._btnflash_click(second.java:431)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:64)
at android.view.View.performClick(View.java:4211)
at android.view.View$PerformClick.run(View.java:17267)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
edit : to complete my post, a same exception occurs with any of these subs :
and switching to the front camera, then back camera again fixes the problem...
I'm still working on my project to launch a camera after double press on power button while the device is pin locked.
Everything seems to work pretty fine but I get once every 4 times a weird exception like the one posted here after.
The camera screen is shown, the panel displays what the camera sees, but when I press on a button (example here the BtnFlash) I get an exception.
When outside the debugger, if I go on with the exception and I press power OFF + power ON to restart the camera, most often it works fine.
The camera activity (named second) is launched from a service (unlock) and just does this:
B4X:
Sub Activity_Resume
SetShowWhenLocked
WS.KeepAlive(True)
Try
InitializeCamera
Catch
Msgbox("fail", "")
End Try
End Sub
Sub SetShowWhenLocked
Dim r As Reflector
r.Target = r.GetActivity
r.Target = r.RunMethod("getWindow")
' r.RunMethod2("addFlags", 6815872, "java.lang.int") 'combination of: FLAG_TURN_SCREEN_ON, FLAG_DISMISS_KEYGUARD, FLAG_SHOW_WHEN_LOCKED and FLAG_KEEP_SCREEN_ON.
r.RunMethod2("addFlags", 2621440, "java.lang.int") 'combination of: FLAG_TURN_SCREEN_ON, FLAG_SHOW_WHEN_LOCKED .
End Sub
Note that I've inserted a try catch around InitializeCamera as it happens to fail too (even is less frequently) ...
Any help would be greatly appreciated !
here is the log :
LogCat connected to: B4A-Bridge: samsung GT-I9305-353575059939011
--------- beginning of /dev/log/main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
** Activity (main) Pause, UserClosed = true **
Installing file.
Installing file.
PackageAdded: package:test.unlock
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (unlock) Create **
** Service (unlock) Start **
** Activity (main) Pause, UserClosed = true **
** Activity (second) Create, isFirst = true **
** Activity (second) Resume **
90
[Height=720, IsInitialized=false, Width=960
]
** Activity (second) Resume **
WakeLock already held.
cameraexclass_getsupportedflashmodes (B4A line: 193)
Return r.RunMethod("getSupportedFlashModes")
java.lang.NoSuchMethodException: getSupportedFlashModes []
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getDeclaredMethod(Class.java:685)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at test.unlock.cameraexclass._getsupportedflashmodes(cameraexclass.java:568)
at test.unlock.second._btnflash_click(second.java:431)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:64)
at android.view.View.performClick(View.java:4211)
at android.view.View$PerformClick.run(View.java:17267)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
edit : to complete my post, a same exception occurs with any of these subs :
B4X:
Public Sub GetSupportedFlashModes As List
r.target = parameters
Return r.RunMethod("getSupportedFlashModes")
End Sub
Public Sub GetSupportedColorEffects As List
r.target = parameters
Return r.RunMethod("getSupportedColorEffects")
End Sub
Public Sub GetPictureSize As CameraSize
r.target = parameters
r.target = r.RunMethod("getPictureSize")
Dim cs As CameraSize
cs.Width = r.GetField("width")
cs.Height = r.GetField("height")
Return cs
End Sub
and switching to the front camera, then back camera again fixes the problem...
Last edited: