Android Question Translating an old app to B4XPages: App runs first time fresh, then crashes.

GuyBooth

Active Member
Licensed User
Longtime User
In my B4XPage_Created sub I run this code:
B4X:
        TMM_Preferences.Initialize
        B4XPages.AddPage("B4XPTMM_PreferencesID", TMM_Preferences)
Further into the B4XMainPage I run a sub to show the page with:
B4X:
B4XPages.ShowPage ("B4XPTMM_PreferencesID")

The first time I run this after a fresh install, the code runs ok. But any time I try to run it again, I get this in the error logs and the app crashes:
B4X:
Sub: B4XMainPage_Run_Main_Setup
Error: page id not found: B4XPTMM_PreferencesID
Ids: (ArrayList) [mainpage]
Error occurred on line: 38 (B4XOrderedMap)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
    at b4a.TMMX.b4xpagesmanager._showpage(b4xpagesmanager.java:520)
    at b4a.TMMX.b4xpages._showpage(b4xpages.java:91)
    at b4a.TMMX.b4xmainpage$ResumableSub_Run_Main_Setup.resume(b4xmainpage.java:504)
    at b4a.TMMX.b4xmainpage._run_main_setup(b4xmainpage.java:408)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
... etc

This happens in Debug as well as release mode. If I delete the app completely, the first time I compile and run it again it works ok. Then the next time it crashes ... etc etc etc
Any ideas?
 
Top