Google Maps v2未在API 19上显示,但在API 24上显示

时间:2017-06-07 20:13:01

标签: android google-maps google-maps-android-api-2

您好我的应用有问题。 我在其中使用Google Maps v2,它可以在我的手机和使用API​​ 24的模拟器上正常工作。但在具有较低API级别的模拟器和设备上,它不会扫描地图。

here works everything fine

here is showing nothing

这些是我的权限:

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission 
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

我的片段:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_locate_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="xxxxxxxxxxxxxxxxx.activities.LocateActivity">

<Button
    android:id="@+id/set_action"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/colorPrimary"
    android:text="@string/set_button"
    android:textColor="#fafafa" />

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_above="@id/set_action"
    android:layout_alignParentTop="true"
    tools:context=".activities.LocateActivity" />

</RelativeLayout>

和我的活动:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_locate);

    MapFragment mapFragment = (MapFragment) getFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        requestPermissions(LOCATION_PERMS, LOCATION_REQUEST);
    }
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    addOnMapClickListener();
    initLayout();
}

在较旧的设备上,它转到onMapReady()并说成功,但没有显示地图。我希望你能帮助我:)。

0 个答案:

没有答案