Android Question App Doesn't start

juventino883

Member
Licensed User
Longtime User
Hi , I dont know if i'm the only one with this issue, i'm developing an app following the google maps demo example, but some cases when I start the app the screen remain Black and dont load the layout (and remains black untill I close and open again the app) I read in other Thread that maybe could be too many processes in sub activity_create, I have several days with this issue if someone could help me with this I would appreciate

this is my activity_create code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("Main")
    DoEvents   
    If FirstTime Then    
        geocoder1.Initialize("Geocoder1")
        reqManager.Initialize(Me, server_IP&":17178") 'Inicializa conexion con servidor MySQL   
        myfade.Initialize(Activity,Me,"intro.jpg",Gravity.FILL,3000,50,"",False)'Splash screen
    End If
       
     

        If MapFragment1.IsGooglePlayServicesAvailable = False Then
           ToastMessageShow("Google Play services not available.", True)
       Else
           MapFragment1.Initialize("MapFragment1", MapPanel)
           'Este timer sirve para buscar la posicion inicial del usuario al accesar por primera vez en el programa
            T1.Initialize("T1",2000) 'inicializa el timer a 2 seg
            T1.Enabled=True          'habilita el timer
                       
        End If 
   

   
   
End Sub

I try with DoEvents but with no success.
 

juventino883

Member
Licensed User
Longtime User
Hi Erel thanks for your answer, T1 is declared in sub process_global, this is the code of T1_tick

B4X:
Sub t1_tick
'If the GPS position is available, show in the map where i'm located, else it show a toast message acquiring position.

    If GoogleMap1.MyLocation.IsInitialized=True Then
        
        T1.Enabled=False
        ToastMessageShow("inicializado", False)  
        Label1.Text= GoogleMap1.MyLocation.Latitude
        Label2.Text= GoogleMap1.MyLocation.Longitude

               
'--------Geocoder ------------------------------------------------------------------------       
           
        Dim MaxResults As Int
        MaxResults=5
        
        geocoder1.GetFromLocation(GoogleMap1.MyLocation.Latitude, GoogleMap1.MyLocation.Longitude, MaxResults, Null)
'--------------------------------------------------------------------------------------------       
               
        Dim MarkerOptions1 As MarkerOptions
        MarkerOptions1.Initialize
       
        MarkerOptions1.Position2(GoogleMap1.MyLocation.Latitude, GoogleMap1.MyLocation.Longitude).Snippet("Home is where the heart is").Title("Home Sweet Home").Visible(True)
   
       
        Dim BitmapDescriptor1 As BitmapDescriptor
        Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
   

        BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("ht1.2.png")
       
        MarkerOptions1.Icon(BitmapDescriptor1)
       
       
        Marker_usr=GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)
        Marker_usr.Draggable=True
       
        Dim OnMarkerDragListener1 As OnMarkerDragListener
        OnMarkerDragListener1.Initialize("OnMarkerDragListener1")
       
        If OnMarkerDragListener1.IsInitialized Then
            GoogleMapsExtras1.SetOnMarkerDragListener(GoogleMap1, OnMarkerDragListener1)
        Else
            Log("OnMarkerDragListener1 is not initialized - check that the Activity contains at least one callback Sub")
        End If
       
       
        'shows where I'm located
        Dim CameraPosition2 As CameraPosition        
        CameraPosition2.Initialize(GoogleMap1.MyLocation.Latitude, GoogleMap1.MyLocation.Longitude, 17)
        GoogleMap1.AnimateCamera(CameraPosition2)
           

       
    Else 
        ToastMessageShow("Adquiriendo posicion",False)
       
    End If
End Sub

I remove DoEvents and the splash screen implementation to test, but I still have the problem....
 
Upvote 0

juventino883

Member
Licensed User
Longtime User
Hi Erel I was making the small project to upload but during this I think I find the solution, the problem was in starter service because I set it with these attributes:

#Region Service Attributes
#StartAtBoot: True
#ExcludeFromLibrary: True
#StartCommandReturnValue: android.app.Service.START_STICKY
#End Region

and i set StartServiceAt(Me, DateTime.Now + 5 * DateTime.TicksPerMinute, True)

this because i use the starter service for handling XMPP communication and push notifications so when i comment start_sticky and StartServiceAt the problem does not arise, so I think i need to use separate services for xmpp and push notifications, what do you think about that?, i know in versions of android above 4.4.2 the os kills the sticky services so i dont know what is the best approach for sticky services, what do you recommend?
 
Upvote 0

Similar Threads

  • Question
Android Question mpChartLib
Replies
7
Views
1K
  • Question
Android Question exit app
Replies
7
Views
2K
Top