Android Question Kiosk Service and B4A version 8.0

William Hunter

Active Member
Licensed User
Longtime User
I am recompiling an app in B4A version 8.0, using the Kiosk Service. All was well using B4A version 7.80. But now I am getting this error in the Log.
B4X:
*** Service (kioskservice) Create ***
kioskservice_service_create (java line: 174)
java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
    at anywheresoftware.b4a.objects.NotificationWrapper.getND(NotificationWrapper.java:91)
    at anywheresoftware.b4a.objects.NotificationWrapper.setValue(NotificationWrapper.java:122)
    at anywheresoftware.b4a.objects.NotificationWrapper.setSound(NotificationWrapper.java:108)
    at mail.purge.whapp.kioskservice._service_create(kioskservice.java:174)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at mail.purge.whapp.kioskservice.onCreate(kioskservice.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
    at android.app.ActivityThread.-wrap4(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
java.lang.RuntimeException: Unable to create service mail.purge.whapp.kioskservice: java.lang.RuntimeException: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2887)
    at android.app.ActivityThread.-wrap4(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at mail.purge.whapp.kioskservice.onCreate(kioskservice.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
    ... 8 more
Caused by: java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
    at anywheresoftware.b4a.objects.NotificationWrapper.getND(NotificationWrapper.java:91)
    at anywheresoftware.b4a.objects.NotificationWrapper.setValue(NotificationWrapper.java:122)
    at anywheresoftware.b4a.objects.NotificationWrapper.setSound(NotificationWrapper.java:108)
    at mail.purge.whapp.kioskservice._service_create(kioskservice.java:174)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    ... 11 more
This is the link to the Kiosk Service I am using:
https://www.b4x.com/android/forum/threads/android-kiosk-mode-tutorial.10839/

I have read the tutorial re Automatic Foreground Mode, but I am not sure of what changes need to be made in the Kiosk Service. I have searched the forum to see if there is any reference to this problem, and can find none. Can anyone help me with this?

Regards :)
 
Last edited:

William Hunter

Active Member
Licensed User
Longtime User
Check the code that creates notifications. Change the order of methods. Notification.SetInfo should be the last call.
Thank you Erel, this resolved the issue. For those interested, the Sub below is part of Kiosk Service. You can see that Notification has been moved to be the last call.
B4X:
Sub Service_Create
    pe.Initialize("pe")
    If Notification.IsInitialized = False Then
        Notification.Initialize
        Notification.Icon = "icon"
        'Notification.SetInfo("Kiosk app", "Kiosk app", Main) 'Change the order of methods. Notification.SetInfo should be the last call.
        Notification.Sound = False
        Notification.Vibrate = False
        Notification.SetInfo("Kiosk app", "Kiosk app", Main)
    End If
    Timer1.Initialize("Timer1", 300)
End Sub
Regards
 
Upvote 0
Top