これについていくつか質問があることは知っていますが、どれも役に立ちませんでした。
Sony Xperia (API 14) でデバッグしていますが、常にズーム ボタン (+ と -) で白い画面が表示されます。しかし、Galaxy Nexus で同じコードをテストしたところ、マップが表示されました。
別のデバイスでは機能しているが、私のデバイスでは機能していない場合は、API キーの問題、権限の問題、レイアウトまたはコードの問題ではないと思います。GooglePlayServices も確認しましたが、常に SUCCEED が返されます。
これはレイアウトコードです:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
</LinearLayout>
これはJavaコードです:
package com.nanonino.realtor;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.MapFragment;
import android.app.Activity;
import android.app.Dialog;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
public class ByLocation extends Activity {
@Override
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.by_location_list);
setContentView(R.layout.by_location_map);
//if state has a value different from 0...OH OH!!! Problem, you have
//to tell the user to install GooglePlayService in the device
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
switch (resultCode) {
case ConnectionResult.SUCCESS: // proceed
break;
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
case ConnectionResult.SERVICE_DISABLED:
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 1);
dialog.show();
}
}
私はすべてを試したので、多くのインポートがあります。しかし、問題はコードではなくデバイスにあることがわかりました。
何か案が?