This is a continuation of a previous thread from yesterday, where my needed lots of manual initialization of labels and other visual controls.
https://www.b4x.com/android/forum/t...ould-first-be-initialized-re-launching.77947/
On a fresh start (i.e. the app is not in the Android Apps list) it works okay. If the back button is pressed then the app is hidden and is added to the Apps list. Re-launching it from its icon or from the Apps List results in a java error on the first time that I call TabHostExtras.SetTabTitle e.g.
TabHostEx.setTabTitle(TabHost1, "Berth 1", 1)
This code is in the sub Timer2_Tick. It is a bit weird that other calls have already been done involving TabHostEx and TabHost1 in Timer1_Tick, without causing any problems. Basically the app displays a splash screen for the duration of Timer1 then carries on building the main screen.
I am running the app in Release mode with logging enabled via B4A Bridge. My target phone is 4.4.2 (it is an ATEX phone for a customer's unique application) but I get the same problem on my J3 with 5.1.1. Latest versions of B4a and TabHostExtras.
As I said in my last thread, I am very new to B4a but not new to programming, and I was trying to knock up a proof of concept to show a customer next week. Any help appreciated.
Thanks in advance
Simon
Here's the log of the first and second sessions. Initially it's just been installed in the phone and then the back button pressed; then I re-launched it from the Apps List. I have added log entries to show in what order the Subs are called.
Logger connected to: BCom Mobile B.V. EX-SM14
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
Process_Globals called
** Service (starter) Create **
** Service (starter) Start **
Globals called
** Activity (main) Create, isFirst = true **
Activity_Create completed
** Activity (main) Resume **
Activity_Resume called
Timer1_Tick
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Timer2_Tick called
JobName = Job1, Success = true
Timer2_Tick called
Timer2_Tick called
JobName = Job1, Success = true
Timer2_Tick called
Timer2_Tick called
** Activity (main) Pause, UserClosed = true **
Activity_Pause called
sending message to waiting queue (CallSubDelayed - JobDone)
Globals called
** Activity (main) Create, isFirst = false **
Activity_Create completed
running waiting messages (1)
JobName = Job1, Success = false
** Activity (main) Resume **
Activity_Resume called
Timer2_Tick called
main_timer2_tick (java line: 993)
java.lang.NullPointerException
at uk.co.martinpearman.b4a.tabhostextras.TabHostExtras.setTabTitle(TabHostExtras.java:256)
at b4a.example.main._timer2_tick(main.java:993)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
https://www.b4x.com/android/forum/t...ould-first-be-initialized-re-launching.77947/
On a fresh start (i.e. the app is not in the Android Apps list) it works okay. If the back button is pressed then the app is hidden and is added to the Apps list. Re-launching it from its icon or from the Apps List results in a java error on the first time that I call TabHostExtras.SetTabTitle e.g.
TabHostEx.setTabTitle(TabHost1, "Berth 1", 1)
This code is in the sub Timer2_Tick. It is a bit weird that other calls have already been done involving TabHostEx and TabHost1 in Timer1_Tick, without causing any problems. Basically the app displays a splash screen for the duration of Timer1 then carries on building the main screen.
I am running the app in Release mode with logging enabled via B4A Bridge. My target phone is 4.4.2 (it is an ATEX phone for a customer's unique application) but I get the same problem on my J3 with 5.1.1. Latest versions of B4a and TabHostExtras.
As I said in my last thread, I am very new to B4a but not new to programming, and I was trying to knock up a proof of concept to show a customer next week. Any help appreciated.
Thanks in advance
Simon
Here's the log of the first and second sessions. Initially it's just been installed in the phone and then the back button pressed; then I re-launched it from the Apps List. I have added log entries to show in what order the Subs are called.
Logger connected to: BCom Mobile B.V. EX-SM14
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
Process_Globals called
** Service (starter) Create **
** Service (starter) Start **
Globals called
** Activity (main) Create, isFirst = true **
Activity_Create completed
** Activity (main) Resume **
Activity_Resume called
Timer1_Tick
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
Timer2_Tick called
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Timer2_Tick called
JobName = Job1, Success = true
Timer2_Tick called
Timer2_Tick called
JobName = Job1, Success = true
Timer2_Tick called
Timer2_Tick called
** Activity (main) Pause, UserClosed = true **
Activity_Pause called
sending message to waiting queue (CallSubDelayed - JobDone)
Globals called
** Activity (main) Create, isFirst = false **
Activity_Create completed
running waiting messages (1)
JobName = Job1, Success = false
** Activity (main) Resume **
Activity_Resume called
Timer2_Tick called
main_timer2_tick (java line: 993)
java.lang.NullPointerException
at uk.co.martinpearman.b4a.tabhostextras.TabHostExtras.setTabTitle(TabHostExtras.java:256)
at b4a.example.main._timer2_tick(main.java:993)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)