Android Question Empty Activity after long idle of smartphone

Discussion in 'Android Questions' started by DaOel, Mar 19, 2019.

  1. DaOel

    DaOel Member Licensed User

    First of all I have read some quizes and read the guide about life cycle of activities.
    Perhaps i did not read carefully enough, but the bug i am experiencing is not covered by one of the quizes or explanations.

    Bug description:
    ---
    App is started as usual. Smartphone is idle for several hours (for example over night). App is resumed but the layout shown is empty!
    ---
    Remarks:
    I only use variables defined as service global variables. (except of the buttons and EditText, they are declared in Sub Globals of the activity)
    The following code solves the problem but there is always a notification displayed:

    Code:
    Sub Service_Create
      
        nNotify.Initialize
      
        nNotify.Icon = 
    "auto"
        nNotify.Light = 
    True
        nNotify.SetInfo(
    "Termi Service für Sicherungen""Klicke um Termi zu öffnen", Main)
        nNotify.Sound=
    False
        nNotify.Vibrate=
    False

        
    Service.StartForeground(1,nNotify)

    End Sub
    I do not want a notification to be displayed however.


    Without that idle time the problem does not occur. For example i kill the process manually but when resuming app activity is loaded correctly.
    I also tested with developer options 'No Background Services' and switched between apps. This was also causing no problems.
    It seems there is a problem caused with the idle time of several hours.

    Any Ideas?
     
    Last edited: Mar 19, 2019
  2. José J. Aguilar

    José J. Aguilar Well-Known Member Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

  4. DaOel

    DaOel Member Licensed User

    Thank you Jose and Erel for the fast reply.
    @Jose:
    Only the edittext and buttons are stored in sub global. It is no advantage for me to store the values of the edittext or buttons within a KVS. I just want the buttons and textfields to be visible after long idle time, such that the user can start working with app (all over again) after idle time. Correct me if i am wrong, but as far as i know it is sufficient to declare the buttons within Sub Globals. Everytime the Activity.LoadLayout is called it will initialize them again.

    @Erel
    I have seen the video already and there are also some quizes that illustrate that it is a common mistake. My Code looks like this at the start:

    Code:
    Sub Activity_Create(FirstTime As Boolean)

        
    Activity.LoadLayout("ChooseStudent")
        
    Activity.Title = "Schüler Auswahl"
       
           [...]
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    What are you doing in Activity_Pause and Activity_Resume? Is there anywhere in your code a place where you remove views?
     
  6. DaOel

    DaOel Member Licensed User

    Activity Pause and Resume look like this:

    Code:
    Sub Activity_Resume
        RenderLocker
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub RenderLocker
       
        
    Dim bmpSettings As Bitmap
        
    If Starter.UserCode <> "" And Starter.UserCode <> "null" Then
            Starter.BlackLock = 
    True
            bmpSettings.Initialize(
    File.DirAssets,"Schloss_Haken.png")
        
    Else
            Starter.BlackLock = 
    False 
            bmpSettings.Initialize(
    File.DirAssets,"Schloss_Gold.png")
        
    End If

        btnLicense.SetBackgroundImage(bmpSettings)
       
    End Sub
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    The problem is somewhere else. That's all that I can say.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice