Android Question Black screen at the beginning

Discussion in 'Android Questions' started by Pablo Torres, Jul 12, 2018 at 3:24 PM.

  1. Pablo Torres

    Pablo Torres Active Member Licensed User

    Hi, in my android app there is a black screen at the beginning I cannot take away
    It takes 8 seconds to go away
    It is really annoying, I would like to show an image instead of that, I have no idea how to do it

    Can anyone help me please?
     
  2. DonManfred

    DonManfred Expert Licensed User

    Hard to say anything about it as you are missing to post your code.

    I guess you are doing something which causes the 8 Seconds delay...
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    There shouldn't be any reason for your app to start so slow. You are doing too many things in Activity_Create. Load the layout and add Sleep(100) to allow it to show before you do anything else.

    If the layout file is large then split it.
     
  4. Star-Dust

    Star-Dust Expert Licensed User

    Have you completed in release mode?
    Or did you send in debug mode and wait for a connection to the computer?
     
    Erel likes this.
  5. Pablo Torres

    Pablo Torres Active Member Licensed User

    The main module has this code in Activity_Create

    Code:
    ModoVideo=False
        ModoResume=
    3
        
    Activity.LoadLayout("Altius")
        Sleep(
    100)
        
    ProgressDialogShow("INICIANDO APLICACIÓN")
        
    If FirstTime Then
            ConexionGps.Initialize(
    "ConexionGPS")
            auth.initialize(
    "auth")
            player1.Initialize(
    "player")
        
    End If
        
    If Mapa.IsGooglePlayServicesAvailable = False Then
            
    ToastMessageShow("Instale Google Play Services."True)
        
    End If
        ListaPaginas.Initialize
        MyFont=
    Typeface.LoadFromAssets("AvenirNext-Medium.otf")
        userLocation.Initialize2(
    0,0)
        Seleccion=
    0
        intAlto=
    100%y
        intAncho=
    100%x
        intAncho2=intAncho*(
    .94)
        scvGaleria.Initialize(intAncho2,
    "scvGaleria")
        scvGaleria2.Initialize(intAncho2,
    "scvGaleria2")
        IdApartamentoActual=
    0
        IdProyectoActual=
    0
        lstProyectos.Initialize
        lstApartamentos.Initialize
        lstPromos.Initialize
        ListaNombreProyectos.initialize
        listaMensajes.Initialize
        listaNoticias.Initialize
        lstShowrooms.Initialize
        lstShowroomsBilu.Initialize
        lstShowroomsMore.Initialize
        lstShowroomsNostrum.Initialize
        ListaApartamentosFavoritos.Initialize
        ListaProyectosFavoritos.Initialize
        lstBarriosBuscador.Initialize
        lstDormitorios.Initialize
        lstEstados.Initialize
        lstPisos.Initialize
        lstDormitoriosProyecto.Initialize
        lstEstadosProyecto.Initialize
        lstPisosProyecto.Initialize
        CargarShowrooms
        ObtenerPromos
        AjustarControles
        MenuOpen=
    False
        pnlLateral.Visible=
    False
        CargarFondosFijos
        sepVideo.Player = player1
        
    ProgressDialogHide
        
    If File.Exists(File.DirDefaultExternal,"IdCliente_Altius.txt"Then
            IdCliente=
    File.ReadString(File.DirDefaultExternal,"IdCliente_Altius.txt")
            CallSubDelayed(FirebaseMessaging,
    "Service_Create")
            MostrarPanel(pnlSeleccion)
            CargarMensajes
            CargarFavoritos
            btnAbrirSesion.Visible=
    False
        
    Else
            lblOfrecer.Visible=
    False
            MostrarPanel(pnlInicial)
        
    End If
    I also have a Starter module (I think this is the problem) with the following code:

    Code:
    #Region  Service Attributes
        
    #StartAtBoot: False
        
    #ExcludeFromLibrary: true
    #End Region

    Sub Process_Globals
        
    Public auth As FirebaseAuth
        
    Public facebook As FacebookSdk
    End Sub

    Sub Service_Create
        
    Log("AUTH CREATE")
        auth.Initialize(
    "auth")
        facebook.Initialize
    End Sub

    Sub Service_Start (StartingIntent As Intent)
        
    Log("AUTH START")
        Main.ModoResume=
    2
    End Sub

    'Return true to allow the OS default exceptions handler to handle the uncaught exception.
    Sub Application_Error (Error As Exception, StackTrace As StringAs Boolean
        
    Return True
    End Sub

    Sub Service_Destroy
    End Sub
    I dont know how to solve it, by watching the log I can see Starter module starts inmediately and it takes a lot of time before starting to load Altius.bal
    How can I improve it?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. Pablo Torres

    Pablo Torres Active Member Licensed User

    I did everything you said... still same result
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Have you changed the theme colors? It will not be black.

    About the startup time, try to reproduce it in a smaller project and upload it.
     
  9. MarkusR

    MarkusR Active Member Licensed User

    i would make a time measurement class, a simple stop watch where you call start and at stop output the time in ms into Log(..)
    so you can measure a sub from start to end or parts.
    if you found the biggest delays you can change your app flow or logic.
     
  10. Pablo Torres

    Pablo Torres Active Member Licensed User

    I solved
    I created another activity, loaded that activity (only an image) with a timer for 1 second and then loaded the other activity.
    It still takes about 10 second to really start but, all that time remains showing the first activity image and a progressdialog that says "starting activity", so the user dont get the impression the app is freeze.
     
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