Android Question New Starter service

Humberto

Active Member
Licensed User
Longtime User
Hi
I´m using the new Starter service to inicialize all common stuff including language transalator.
At the first time I ask the the language and then I call "activity.Finish" to end the program so the next time the language comes.
But when I call the program again it doesn´t execute the "Starter" again .

Bellow is the log

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Primeira vez solicitar lingua
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
main_activity_create (java line: 386)
java.lang.RuntimeException: Object should first be initialized (Map).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.collections.Map.ContainsKey(Map.java:120)
at de.amberhome.locale.AHTranslator.GetText(AHTranslator.java:161)
at hsp.sos.main._activity_create(main.java:386)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at hsp.sos.main.afterFirstLayout(main.java:102)
at hsp.sos.main.access$000(main.java:17)
at hsp.sos.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main

After "Primeira vez solicitar lingua"

Do I must call "Starter" by code ?
 

Rick A.

Member
Licensed User
Longtime User
That's how it works. The service is started and keeps there all the time until being finished by your code ( StopService(Starter) ) or some probably very rare system event. You should notice that the service does not have a "FirstTime" parameter, it's because the Starter.Service_Start should occur just once for the entire app lifecicle. Set your Process_Globals values as necessary, and maintain your machine states as you intend after the start between its activities.
 
Last edited:
Upvote 0

Humberto

Active Member
Licensed User
Longtime User
The object AHTranslator is declared in "Starter" but at the first time I didn´t initiaze it because I don´t know the language yet.

How can I finish the apk so the next time execute the "Starter" ?

I ended with "Activity.Finish" but it just "Pause" the apk.
 
Upvote 0

Humberto

Active Member
Licensed User
Longtime User
Instead of initialize the things in a "Service_Create" I do it in a function, so at the first time I will ask the language to the user and then I call that function , and the next time the software starts I call it in "Service_Create" .

Thanks
 
Upvote 0
Top