java.lang.RuntimeException:无法实例化活动ComponentInfo n.mpo.mpmobile.KioskListLocation

时间:2017-07-17 06:12:21

标签: android google-maps

{in.mpo.mpmobile / in.mpo.mpmobile.KioskListLocation}:

java.lang.ClassCastException: in.mpo.mpmobile.KioskListLocation cannot be cast to android.app.Activity

KioskListLocation类:

public class KioskListLocation extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.acctivity_kiosk_location, container, false);        

        mMapView = (MapView) rootView.findViewById(R.id.mapView);
        mMapView.onCreate(savedInstanceState);
        mMapView.onResume(); // needed to get the map to display immediately

        try 
        {
            MapsInitializer.initialize(getActivity().getApplicationContext());
        }
        catch (Exception e) {
            e.printStackTrace();
        }

        mMapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(GoogleMap mMap) {
                googleMap = mMap;

                // For showing a move to my location button
                googleMap.setMyLocationEnabled(true);

                // For dropping a marker at a point on the Map
                LatLng sydney = new LatLng(-34, 151);
                googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").snippet("Marker Description"));

                // For zooming automatically to the location of the marker
                CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build();
                googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
            }
        });
        return rootView;
    }
}

1 个答案:

答案 0 :(得分:0)

您的代码清单缺少类声明。

我猜你忘了延长活动。

您应该重新格式化并扩展您的商家信息。