Android Question [solved] TabHost access or TabHostEx.SetTabTitle causes RTE only when app resumed

SimonInCanada

Member
Licensed User
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)
 

Attachments

  • Wifi App 2.zip
    18.3 KB · Views: 272

DonManfred

Expert
Licensed User
Longtime User
You should use quote tag when posting logs.
Code tags when posting code. Not true here but i wan to say it too for the future ;)

codetag001.png

codetag002.png

Use the Quote for posting logs...

using code you can add them in the following window
codetag003.png
 
Upvote 0

SimonInCanada

Member
Licensed User
You should use quote tag when posting logs.
Code tags when posting code. Not true here but i wan to say it too for the future ;)

codetag001.png

codetag002.png

Use the Quote for posting logs...

using code you can add them in the following window
codetag003.png

Ok thanks. How do I mark my thread solved? (see below)

Simon
 
Upvote 0

SimonInCanada

Member
Licensed User
I have solved this one myself. What is supposed to happen is that the app is launched then displays a splash screen and starts Timer1. Timer1_Tick then initialises the main views and starts Timer2 which then paces the app. But when the app was re-launched Timer2 is already started and times out before Timer1, so at that point the TabView1 has not been set up properly and this causes the problem when calling TabViewExtras.SetTabText. I have fixed this for now so if Timer1_Tick has not run yet, Timer2_Tick simply exits.

I am rather confused about this Timer behaviour on resume. I'll read up some more. Also, even though I thought I cancelled the HttpJob in the Pause Sub, the current Job if there is one (and there usually is) on pausing gets reactivated soon after Activity_Create and calls JobDone with a success result.

Anyway thanks anybody who has advised me.

Simon
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
How do I mark my thread solved?
See upper right of the Thread. There is a link to THREAD TOOLS... Chosse Edit Title and change the Thread-Title
from (in this case):
TabHost access or TabHostEx.SetTabTitle causes RTE only when app resumed

to:

[solved] TabHost access or TabHostEx.SetTabTitle causes RTE only when app resumed
 
Upvote 0
Top