Android: Problema com Google Map Api

Psycop

I fold therefore I AM
Boas

Tenho estado a tentar fazer umas experiências com Android e a localização apresentando a mesma no mapa usando a Api da google, no entanto não estou a conseguir obter o resultado esperado, como mostra a imagem.

exp.png


coloquei o seguinte no manifest:

XML:
<permission
 android:name="com.nuno.exp.permission.MAPS_RECEIVE"
 android:protectionLevel="signature"/>

 <uses-feature
 android:glEsVersion="0x00020000"
 android:required="true"/>
 <uses-permission android:name="com.nuno.exp.permission.MAPS_RECEIVE"/>
 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data
  android:name="com.google.android.*****.version"
  android:value="@integer/google_play_services_version"/>

  <meta-data
  android:name="com.google.android.maps.v2.API_KEY"
  android:value="<chave_google>"/>

Na activity tenho o Seguinte:

Java:
import android.content.pm.ActivityInfo;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.onclickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Dialog;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import com.google.android.*****.common.ConnectionResult;
import com.google.android.*****.common.GooglePlayServicesUtil;
import com.google.android.*****.maps.CameraUpdateFactory;
import com.google.android.*****.maps.GoogleMap;
import com.google.android.*****.maps.SupportMapFragment;
import com.google.android.*****.maps.model.LatLng;

public class Localizacao_ActualActivity extends FragmentActivity implements LocationListener {

GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Bloquear Orientação Ecrã a Portrait
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_localizacao__actual);

//Button Retroceder
  Button button_retroceder = (Button) findViewById(R.id.button_retroceder);
  button_retroceder.setonclickListener(new onclickListener()
  {
  @Override
  public void onclick(View v)
  {
  //Iniciar nova Activity
  Intent button_retrocederIntent = new Intent(getApplicationContext(), MainActivity.class);
  finish();
  }
  });

// Getting Google Play availability status
  int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

  // Showing status
  if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available

  int requestCode = 10;
  Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
  dialog.show();

  }else { // Google Play Services are available

  // Getting reference to the SupportMapFragment of activity_main.xml
  SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

  // Getting GoogleMap object from the fragment
  googleMap = fm.getMap();

  // Enabling MyLocation Layer of Google Map
  googleMap.setMyLocationEnabled(true);

  // Getting LocationManager object from System Service LOCATION_SERVICE
  LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

  // Creating a criteria object to retrieve provider
  Criteria criteria = new Criteria();

  // Getting the name of the best provider
  String provider = locationManager.getBestProvider(criteria, true);

  // Getting Current Location
  Location location = locationManager.getLastKnownLocation(provider);

  if(location!=null){
  onLocationchanged(location);
  }
  locationManager.requestLocationUpdates(provider, 20000, 0, this);
  }
  }
  @Override
  public void onLocationchanged(Location location) {

  TextView tvLocation = (TextView) findViewById(R.id.tv_location);

  // Getting latitude of the current location
  double latitude = location.getLatitude();

  // Getting longitude of the current location
  double longitude = location.getLongitude();

  // Creating a LatLng object for the current location
  LatLng latLng = new LatLng(latitude, longitude);

  // Showing the current location in Google Map
  googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

  // Zoom in the Google Map
  googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));

  // Setting latitude and longitude in the TextView tv_location
  tvLocation.setText("Latitude:" + latitude + ", Longitude:"+ longitude );

  }

  @Override
  public void onProviderDisabled(String provider) {
  // TODO Auto-generated method stub
  }

  @Override
  public void onProviderEnabled(String provider) {
  // TODO Auto-generated method stub
  }

  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) {
  // TODO Auto-generated method stub
  }
}

E por fim no layout:

XML:
<TextView
  android:id="@+id/tv_location"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />

<fragment
  android:id="@+id/map"
  android:name="com.google.android.*****.maps.MapFragment"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_above="@+id/button_retroceder"
  android:layout_below="@+id/tv_location"
  android:layout_marginTop="0dp"
  class="com.google.android.*****.maps.SupportMapFragment" />


Alguém me sabe dizer o que poderá estar errado?

Cumprimentos
 
Não li nada que está no teu código, mas pela imagem deduzo que tenha a ver com a chave da API. Tenta perceber se estás a utilizar uma chave para Debug ou para Release e se esta está a condizer com a que aparece na Console da Google.
 
Back
Topo