Java 谷歌地图在我的android应用程序中显示空白页面?
我正在尝试在pizza应用程序中实现google my app,但它显示空白页我该怎么办 下面是我的java代码Java 谷歌地图在我的android应用程序中显示空白页面?,java,android,google-maps,Java,Android,Google Maps,我正在尝试在pizza应用程序中实现google my app,但它显示空白页我该怎么办 下面是我的java代码 public class FindUsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(
public class FindUsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_us);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng sydney = new LatLng(56.855776, 14.829839);
Marker DSlocation = mMap.addMarker(new MarkerOptions().position(sydney).title("Maestro restaurang &
pizzeria").snippet("Click Navigation icon below for navigation"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,18));
} }
我的xml文件
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.yodgor777.maestro.FindUsActivity" />
我的舱单
<?xml version="1.0" encoding="utf-8"?> <manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yodgor777.maestro">
使用时不需要访问\u粗略/精细\u位置权限
谷歌地图Android API v2,但您必须指定粗糙或精细
“MyLocation”功能的位置权限。
-->
在manifest.xml中添加此权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
更改您的google map api键,然后在google map api
键是否为enable
时尝试并检查
启用地图API
接下来,添加包名和指纹。这提供了两个字段,一个用于添加包名,另一个用于从应用程序签名密钥添加SHA1
可以使用以下命令生成SHA1:
创建SHA1密钥并将其输入文本字段后,单击蓝色的“创建”按钮。然后,您将看到一个对话框,其中包含需要添加到Android应用程序以访问地图API的API密钥
参考人:
:我已经实现了新的api密钥,并添加了您的代码以显示它仍然显示为空。-->AIzaSyBnJFSGMRpgyBogcfwAHM8JSfuJ4c1FNaM
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
keytool -list -v -keystore debug.keystore