I know there are some questions about this, but none of them helped me.
I'm debugging with a Sony Xperia (API 14) and I always get a white screen with the zoom buttons (+ and -). But I have tested the same code with a Galaxy Nexus and I can see the map.
If it's working in another device but not in mine, I guess it is not an API key problem, permission problem, layout or code problem. I also have checked the GooglePlayServices and is always returning SUCCEED.
This is the layout code:
<?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>
This is the java code:
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();
}
}
I have many imports because I have tried everything. But now I know that the problem is with the device, not the code.
Any idea?