Android Question MapFragment1_Ready question

josnav

Member
Licensed User
HI!!!!
If I run my app first time, MapFragment1_Ready is not executed never... but if I close my app and then re-execute it works always until next reboot device.
First time reboot device and run my app, MapFragment1_Ready is not executed, second time my app runs, and ALL WORKS.

Why happend this at first time?


Thanks
Jose
 

eurojam

Well-Known Member
Licensed User
Hi Jose,
It will be easier to help, if you post your code or parts of it and logs...

best
stefan
 
Upvote 0

josnav

Member
Licensed User
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim valores(8) As Int
Dim resumen As String
Dim GPS1 As GPS
Dim zoom As String=20
Dim config As KeyValueStore
Dim p1, p2 As Location
Dim Lat2 As Double = 0
    Dim Lon2 As Double = 0  
   
Dim latitud As Double=0

Dim longitud As Double=0
    Dim Distance As Float=0
Dim Distance2 As Float=0
End Sub

Sub Globals
    Dim poweron As Boolean=False
   
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    'multiplicar por 3.6 para kilometros hora la velocidad que está en metros por segundo
    Dim bm(12) As Bitmap
   
   
   
    Dim reloj As Label
   
    Private gmap As GoogleMap
   Private MapFragment1 As MapFragment
    Private Panel1 As Panel
    Private ImageView1 As ImageView
    Private ImageView2 As ImageView
    Private Label1 As Label
   
    Private ImageView3 As ImageView
   
   
    Private ImageView4 As ImageView
    Private Label2 As Label
   
    'Private Label6 As Label
    Private ImageView10 As ImageView
    Private ImageView7 As ImageView
    Private ImageView8 As ImageView
    Private ImageView9 As ImageView
    Private ImageView11 As ImageView
    Private ImageView12 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
     If FirstTime Then
        GPS1.Initialize("GPS")
    End If
    Activity.LoadLayout("Inicio")
        Activity.AddMenuItem("Salir","salir")
   
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
     ToastMessageShow("Los Servicios de Google Play no estan disponibles.", True)
    
   End If
End Sub
Sub MapFragment1_Ready
   gmap = MapFragment1.GetMap
    If gmap.IsInitialized = False Then
      ToastMessageShow("Error al iniciar Mapa.", True)
    Else
    gmap.MapType = gmap.MAP_TYPE_NORMAL
    gmap.MyLocationEnabled = True
    gmap.GetUiSettings.MyLocationButtonEnabled =False
    gmap.GetUiSettings.TiltGesturesEnabled = False
    gmap.GetUiSettings.ZoomGesturesEnabled = False
    gmap.GetUiSettings.CompassEnabled = False
    gmap.GetUiSettings.RotateGesturesEnabled = True
    gmap.GetUiSettings.ZoomControlsEnabled = False
    gmap.GetUiSettings.AllGesturesEnabled=False
    End If
End Sub

Sub Activity_Resume
If GPS1.GPSEnabled = False Then
        ToastMessageShow("Por favor, active el sistema GPS de su dispositivo.", True)
        StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
    Else
        GPS1.Start(0, 0) 'Listen to GPS with no filters.
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
  GPS1.Stop
End Sub
Sub GPS_LocationChanged (Location1 As Location)
        latitud=Location1.latitude
        longitud=Location1.Longitude
                p2.Initialize2(latitud,longitud)
        p1.Initialize2(Lat2, Lon2)
               
       
        Distance  = p1.DistanceTo(p2)
       
        velocidad=Round2((Location1.Speed*3.6),1)
       
    If latitud <> 0 And longitud <> 0 Then
    If Distance > 10 Then
        If poweron And Location1.Speed>0 Then
       
        Distance2=Distance+Distance2
       
        End If
       
       
    Lat2 = latitud
    Lon2 = longitud
    Dim cp As CameraPosition

    cp.Initialize2(Location1.Latitude, Location1.Longitude, 16, Location1.Bearing, 0)
  
   If gmap.IsInitialized Then  gmap.AnimateCamera(cp)
   
   
    If velocidadanterior=0 Then velocidadanterior=Ceil(Location1.Speed*3.6)
   
   
    End If
    End If
   
   
   
   
   
    If poweron Then
       
    If Ceil(Location1.Speed*3.6)<velocidadanterior-(Ceil(velocidadanterior*offsetvelocidad)/100) And modotrabajo="2"   Then
       
        If avisovelocidad=False Then
            avisovelocidad=True
       
        'hay variacion vibramos
        If vibracion="SI" Then
       
        Dim vibra As PhoneVibrate
       
        vibra.Vibrate(2000)
       
        End If
   
        ToastMessageShow("Desviacion de velocidad por debajo del " & offsetvelocidad & "%",True)
        
       
           
            End If
       
       
       
   
    Else
       
        avisovelocidad=False
   
   
   
   
       
    End If
   
    End If
   
       
End Sub
Sub GPS_UserEnabled (Enabled As Boolean)
End Sub
Sub GPS_GpsStatus (Satellites As List)
 
End Sub


Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
   
   
ExitApplication
Activity.Finish

End If
Return True

End Sub




Sub ImageView19_LongClick
    If PRIMERAVEZ Then
    

    StartActivity(vehiculo)
  
  
  
        If execonfigura=True Then
            execonfigura=False
            StartActivity(configura)
           
        End If
       
   
   
   
   
    PRIMERAVEZ=False
   
End If
End Sub
 
Upvote 0
Top