Android Question Google Maps error

hatzisn

Expert
Licensed User
Longtime User
Hi everybody,

what can you make out of this error? I cannot understand what I am doing wrong...

** Activity (setpreffered) Create, isFirst = true **
** Activity (setpreffered) Resume **
java.lang.ClassCastException: com.google.maps.api.android.lib6.impl.am cannot be cast to android.view.ViewGroup
at android.app.BackStackRecord.configureTransitions(BackStackRecord.java:1300)
at android.app.BackStackRecord.beginTransition(BackStackRecord.java:1021)
at android.app.BackStackRecord.run(BackStackRecord.java:728)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1582)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:483)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)


This is the code that deals with the map:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("5")
 
   
    If mFragment.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Google Play services not available.", True)
        bMap = False
    Else
        bMap = True
    End If
   
   
    If bMap = False Then
        Return
    End If
   
    pnlMap.Visible = True
       
    gblLat = 38.017112
    gblLong = 23.542476
   
    mFragment.Initialize("Map", pnlMap)
    lMarkers.Initialize
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Map_Ready
    Log("map ready")
    gmap = mFragment.GetMap
    gmap.MapType = gmap.MAP_TYPE_SATELLITE
   
    If bMap = True Then
        '
    Else
        ToastMessageShow("Google play services is not available.",True )
    End If
    If gmap.IsInitialized = False Then
        ToastMessageShow("Error initializing map.", True)
    Else
        SetMapPositionToMarker
    End If
End Sub

Sub SetMapPositionToMarker
    sMarkTitle = "38.017112, 23.542476"
    Dim m1 As Marker = gmap.AddMarker(gblLat, gblLong, sMarkTitle)
    lMarkers.Add(m1)

    Dim cp As CameraPosition
    cp.Initialize(gblLat, gblLong, 17)
    gmap.AnimateCamera(cp)
End Sub

I have placed a bookmark in the line:
B4X:
    Log("map ready")

and it never gets there.

Thanks in advance...
 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
Hi Erel,

thanks for the advice. It works by placing the code in the "Map_Ready" and the "SetMapPositionToMarker" in the "mFragment_Ready" sub.
I am writting it in case any one else faces the same problem as I already have followed the tutorial you suggested (well, not totally to the end as it seems :) ).

Thanks for your time
 
Upvote 0
Top