当我将我的 Activity 更改为另一个有华为 map 的 Activity 时,打开速度非常慢。
huawei version is MED-LX9N
Android version is 10
Ram : 3.0 GB
and free space is 52 / 64 GB
当我点击更改 Activity 按钮时,它首先等待 3-5 秒。
然后我返回页面并再次返回 map 页面它只等待 1 秒。
我的代码:
com.huawei.hms.maps.SupportMapFragment supportMapFragment = new com.huawei.hms.maps.SupportMapFragment();
context.getSupportFragmentManager().beginTransaction().replace(fragmentId, supportMapFragment).commit();
supportMapFragment.getMapAsync(huwaiMapReadyCallBack);
map 异步:
com.huawei.hms.location.FusedLocationProviderClient fusedLocationProviderClient = com.huawei.hms.location.LocationServices.getFusedLocationProviderClient(activity);
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(activity, location -> {
if (location != null) {
double currentLat = location.getLatitude();
double currentLong = location.getLongitude();
com.huawei.hms.maps.model.LatLng latLng = new com.huawei.hms.maps.model.LatLng(currentLat, currentLong);
com.huawei.hms.maps.CameraUpdate cameraUpdate = com.huawei.hms.maps.CameraUpdateFactory.newLatLngZoom(latLng, zoom);
huaweiMap.moveCamera(cameraUpdate);
}
});
在 xml 上:
<fragment
android:id="@+id/map_fragment"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="350dp" />
它工作但很慢我该如何解决这个问题?正常吗?
最佳答案
我在我的应用程序中使用了 Mapbox map Activity 。这在华为设备中打开也很慢。所以我将 map 加载的初始缩放级别设置为 14.0 以加快加载速度。现在可以了。
关于java - 华为Map Kit Activity打开很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65435463/