Android Question [Solved] StartServiceAtExact fails in my project

asales

Expert
Licensed User
Longtime User
I'm trying to migrate my old projects (that is non b4xpages) to Android 31.

Some projects has an alarm in 3 times of the day.

I use this code to calculate the next schedule.
And this code to the service with notification:
B4X:
t = FindNextTime(Array As Double(10+30/60, 15+30/60, 20+30/60))
CancelScheduledService(Alarme)
'StartServiceAt(Alarme,t,True)
 StartServiceAtExact(Me,t,True)
If I change the StartServiceAt to StartServiceAtExact, I get this error below when the app starts.
If I use StartServiceAt, I don't get this error.

I tried to reproduce this error in a small project (activity and b4xpages) without success.

What could be the problem?

Any help are welcome. Thanks.

B4X:
main_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2 (java line: 887)
java.lang.ClassNotFoundException: br.com.apps.profile.main$main_BR
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:454)
    at java.lang.Class.forName(Class.java:379)
    at anywheresoftware.b4a.keywords.Common.getComponentClass(Common.java:978)
    at anywheresoftware.b4a.keywords.Common.createPendingIntentForAlarmManager(Common.java:947)
    at anywheresoftware.b4a.keywords.Common.StartServiceAtExact(Common.java:938)
    at br.com.apps.profile.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv2(main.java:887)
    at br.com.apps.profile.main._criar_menu(main.java:2133)
    at br.com.apps.profile.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv0(main.java:1943)
    at br.com.apps.profile.main._startpage(main.java:5325)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1084)
    at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:1031)
    at br.com.apps.profile.main$ResumableSub_SplashAnimation.resume(main.java:5284)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1716)
    at android.os.Handler.handleCallback(Handler.java:914)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:225)
    at android.app.ActivityThread.main(ActivityThread.java:7563)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)
Caused by: java.lang.ClassNotFoundException: br.com.apps.profile.main$main_BR
    ... 23 more
 

asales

Expert
Licensed User
Longtime User
My bad. Thanks for the clarification.
I passed "Me" instead the service name.
Correct code:
B4X:
StartServiceAtExact(Alarme,t,True)
 
Upvote 0
Top