Android Question Strange crash in GoogleMap

marcick

Well-Known Member
Licensed User
Longtime User
I have (very rarely) a crash in Mapfragment_Ready event.
Can you guess why ?

B4X:
Sub MapFragment1_Ready   
    Log("MapFragment1_Ready")
    GoogleMap1=MapFragment1.GetMap
        If GoogleMap1.IsInitialized = False Then
            ToastMessageShow("Error initializing map", True)
        Activity.Finish
     End If   
    GoogleMap1.MapType= MySub.TileType           <<----- this is the crash line 
    'ìì--------- beginning of crash
    'java.lang.RuntimeException: Object should first be initialized (GoogleMap).
    'at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    'at anywheresoftware.b4a.objects.MapFragmentWrapper$GoogleMapWrapper.setMapType(MapFragmentWrapper.java:297)
    'at it.xxxxx.main._mapfragment1_ready(main.java:7605)

Myme it should be intented that MySub.TileType is not initialized (and not GoogleMap) ?
 

marcick

Well-Known Member
Licensed User
Longtime User
That means sometime I have the Mapfragment_ready event but getmap fails ?
Why ?
And how to manage this situation in a nice way ? Anyway doesn't look good if I close the application .
 
Upvote 0
Top