Android Question App not starting in main

billmoultrie

Member
Licensed User
Longtime User
I am running an app with a service module which checks for data on a server.
If I stop the app and leave the service module running when I restart the app I get an error message saying 'object not initialized (Label)' and I believe what is happening is that it starts in the service module and on completing and going to the Main routine it thinks that objects have not been initialized.
If I then do not 'continue' and then start the app again it works OK.

Any ideas?
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
If I stop the app and leave the service module running when I restart the app I get an error message saying 'object not initialized (Label)'
Hello,
Could you please post the Main's code (especially Activity_Create and Activity_Resume).
 
Upvote 0

billmoultrie

Member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
  

    Log("Start main")
    phone1.SetScreenOrientation(1) ' fix as portrait

    ListView1.Initialize("ListView1")

    Activity.AddView(ListView1, 0%x, 10%y, 40%x, 80%y)
  
    If FirstTime Then

        Log("first time ")  
        Activity.LoadLayout("Main")
      
        Log("++++++++++Counter "&IsPaused(Counter))
        serv = 1
        StartService(Counter)

        Get_Screen_Resolution      
    End If
  
    DoEvents

B4X:
Sub Activity_Resume

End Sub

Code shown above from 'Main'

Hello,
Could you please post the Main's code (especially Activity_Create and Activity_Resume).
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
The error you get is because you are loading the layout only when FirstTime is True
You must move the line outside the test

B4X:
Sub Activity_Create(FirstTime As Boolean)
      Activity.LoadLayout("Main")
...
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…