android地图仅在发布活动中有效
我尝试了很多,但仍然没有解释/解决方案,为什么地图没有加载 我正在使用 AndroidStudio、GoogleMapv2、GooglePlayServices7.5.0以及使用SHA1创建api密钥等 我有一个名为TestMapAct.class的活动,它包含在应用程序中显示地图所需的代码 如果我将TestMapAct作为我的启动程序活动,则Map可以工作 当我在启动活动后调用Map时,它会工作。 如果我像这样调用splash activity->Login activity->TestMapAct,则Map不起作用 这是我的TestMapAct类android地图仅在发布活动中有效,android,dictionary,Android,Dictionary,我尝试了很多,但仍然没有解释/解决方案,为什么地图没有加载 我正在使用 AndroidStudio、GoogleMapv2、GooglePlayServices7.5.0以及使用SHA1创建api密钥等 我有一个名为TestMapAct.class的活动,它包含在应用程序中显示地图所需的代码 如果我将TestMapAct作为我的启动程序活动,则Map可以工作 当我在启动活动后调用Map时,它会工作。 如果我像这样调用splash activity->Login activity->TestMap
package com.propstack.propstack.activities;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.propstack.propstack.R;
/**
* Created by propstack on 06-11-2015.
*/
public class TestMapAct extends FragmentActivity {
private static GoogleMap mMap;
private static Double latitude, longitude;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_location_info);
latitude = 26.78;
longitude = 72.56;
setUpMapIfNeeded();
}
public void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.location_map)).getMap();
// mMap = ((SupportMapFragment) ProfileActivity.fragmentManager
// .findFragmentById(R.id.location_map)).getMap();
// Check if we were successful in obtaining the map.
if (mMap != null)
setUpMap();
}
}
private static void setUpMap() {
// For showing a move to my loction button
mMap.setMyLocationEnabled(true);
// For dropping a marker at a point on the Map
mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("My Home").snippet("Home Address"));
// For zooming automatically to the Dropped PIN Location
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,
longitude), 12.0f));
}
}
对应的XML代码:-
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/location_map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
请在此帮助我如果您的应用程序已启用SSL锁定,请将此域中的服务器证书添加到您的SSLSocketFactory密钥库中,然后使用HostnameVerifier验证主机名。这就是我用类似的行为解决问题的方法。你能给我看一下清单中的活动吗。?您是否在manifest.xml中声明了它?是的,当然我已经声明了manifest中的活动我建议了3件事:将Play Services更新到最新的8.3.0,使用最新的支持活动类
AppCompatActivity
,并在MapReadyCallback上使用implements
在map准备好使用时获取回调。
<permission
android:name="com.propstack.propstack.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.propstack.propstack.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Key goes here" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
ContextImpl﹕ Failed to ensure directory: /storage/sdcard1/Android/data/com.propstack.propstack/cache