0

私はAndroidが初めてで、Googleマップアクティビティを備えたAndroidアプリで作業しています。私はキーストアを使ってアプリケーションに署名し、APIキーを生成しました。すべてうまくいきました。私はアプリ内に文字列としてAPIキーを配置し、アクセス許可とキーをAndroidマニフェストに追加しました。 APIがGoogleのデベロッパーコンソールで有効になっているかどうかを確認しました。それはすべて正常に見える、私はLogcatにもエラーを取得しないでも、アプリをクラッシュしない - しかし、私はマップの活動を開くときに画面内の場所が表示されません。私は開発とテストにMacとSamsung Grand Primeを使用していますが、私は定期的なWiFIを介して接続しています。Googleマップのアクティビティは空白の画面が表示されます

Here'sマップのアクティビティ:

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

    }*/ 
} 

Here's Androidのマニフェスト:

<?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> 

Here'sレイアウトファイル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> 

何私はここに行方不明か間違っていますか?何かヒントや助けをいただければ幸いです。

+1

アクティビティにバインドしているレイアウトを確認してください。あなたによれば、あなたは何か間違っているように見えます。 – dhuma1981

+0

@ dhuma1981 - 大丈夫、ありがとう - アクティビティが使用しているレイアウトファイルを追加しました。ここに何か間違っている? –

+1

なぜWebViewを使用していますか? Google MapsをAndroidに統合する方法についてはGoogleだけで、あなたの回答は – dhuma1981

答えて

1

コードはGoogleマップを作成しません。WebViewのみです。

+0

です。これまでのところありがとうございます。私は指示に従って、ポストでコードを使用し、まだ空白の画面があります。すべて正常に動作し、エラーはありませんが、まだ位置は示されていません。それ以上のヒント? –

+0

Logcat内にメッセージがありますか?それは私たちを助けるかもしれない。 –

+0

@ Mahmoud Ibrahim - ヒントのおかげで、私の問題を解決しました。 Google APIキーに問題があり、修正されました。 –

関連する問題