我在以下位置关注当前位置教程:选择当前位置并在地图上显示详细信息
我不断收到以下运行时异常:
com.google.android.gms.common.api.ApiException:9003:PLACES_API_ACCESS_NOT_CONFIGURED
我尝试了以下步骤:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/api_key" />
Run Code Online (Sandbox Code Playgroud)
我还使用了似乎运行良好的Maps SDK。开发者控制台上同时启用了Maps SDK和Places API。
即使尝试了所有这些步骤,我仍然收到运行时错误:
ApiException:9003:PLACES_API_ACCESS_NOT_CONFIGURED错误
我的代码:
package com.arnav.akapplications.mapfinder;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.PersistableBundle;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import …Run Code Online (Sandbox Code Playgroud) Google Places APIAndroid版中的自动完成小部件服务未按预期工作.我已将片段包含在我的xml页面中,并且还将侦听器活动添加到我的onCreate().
然后我开始执行自动完成片段,我点击我想要搜索的单词的第一个字母,突然而不是显示已onError()执行的建议并关闭.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.akhil.maplocation.MapsActivity" />
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
对此的主要活动是:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
LatLng fromadd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
fromadd = place.getLatLng(); …Run Code Online (Sandbox Code Playgroud) android google-maps google-maps-api-3 google-places-api google-maps-android-api-2