gpt4 book ai didi

java - Google map Activity 显示空白屏幕

转载 作者:行者123 更新时间:2023-12-01 09:34:25 25 4
gpt4 key购买 nike

我是 Android 新手,正在开发带有 Google map Activity 的 Android 应用。我已经使用 keystore 签署了应用程序并生成了 API key ,一切正常。我已将 API key 作为字符串放置在应用程序中,并将权限和 key 添加到 Android list 中。我检查过该 API 是否在 Google 开发控制台中激活,确实如此。一切看起来都很好,我在 Logcat 中没有收到任何错误,也没有使应用程序崩溃 - 但在打开 map Activity 时,我仍然在屏幕上看不到任何位置。我使用 Mac 和 Samsung Grand Prime 进行开发和测试,并通过常规 WiFI 连接。

这是 map Activity :

package de.die_web_agenten.www.batprice;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity {

//private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView myWebView = (WebView) findViewById(R.id.webview);
//myWebView.loadUrl("http://www.batprice.com");

// 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;

// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));

}*/
}

这是 Android list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.die_web_agenten.www.batprice">

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="de.die_web_agenten.www.batprice.permission.MAPS_RECEIVE" />

<permission
android:name="de.die_web_agenten.www.batprice.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />

<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/app_name" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" />
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
/>

<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.google.android.gms:play-services-maps:8.4.0"
android:value="MyAPIkey" />

<activity
android:name=".ResultsActivity"
android:label="@string/title_activity_results"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".TrainingActivity"
android:label="@string/title_activity_training"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".SecondListActivity"
android:label="@string/title_activity_list"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".AndroidBarcodeQrExample"
android:label="@string/title_barcode_class"
android:theme="@style/AppTheme.NoActionBar" />

</application>

</manifest>

这是布局文件 webview.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView android:id="@+id/webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>

我在这里错过了什么或做错了什么?任何提示和帮助将非常感激,谢谢。

最佳答案

您的代码不会创建 Google map ,它只是一个 WebView。

关于java - Google map Activity 显示空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39123491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com