e / placeautocompletead:获取自动完成预测api调用时出错:status {statuscode = places_api_access_not_configured,resolution = null}

时间:2019-05-17 08:55:39

标签: android google-places-api googleplacesautocomplete

我正在寻找解决方案

  

e / placeautocompletead:获取自动完成预测api调用时出错:status{statuscode=places_api_access_not_configured, resolution=null}

但这对我不起作用

改变依赖关系

implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.libraries.places:places:1.1.0'
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback ,
        GoogleApiClient.OnConnectionFailedListener {
    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

    }
    private static final String TAG = "MapActivity";
    private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
    private static final String COARSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
    //////
    private static final LatLngBounds LAT_LNG_BOUNDS = new LatLngBounds(new LatLng(35.536200,6.162896),
            new LatLng(35.536658,6.164081));

    private PlaceAutocompleteAdapter mplaceAutocompleteAdapter ;
   private GoogleApiClient mGoogleApiClient ;
    // caméra zoom
    private static final float Default_zoom = 15f;
    //widgets
    private AutoCompleteTextView mSearchText;
    //private EditText mSearchText;
    private ImageView mgps;

    // aléatoire
    private static final int Location_Permission_Request_Code = 10000;
    private boolean mLocationPermissionGranted = false;
    // permission de localisation
    private FusedLocationProviderClient mFusedLocationProviderClient;
    private GoogleMap mMap;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        getLocationPermission();
        mSearchText = findViewById(R.id.search_text);
        mgps = findViewById(R.id.ic_gps);
    }
    //
    private void init(){
        Log.d(TAG,"init : initializing");

        mGoogleApiClient =  new GoogleApiClient
                .Builder(this)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .enableAutoManage(this,this)
                .build();

        mplaceAutocompleteAdapter = new PlaceAutocompleteAdapter(this,mGoogleApiClient,LAT_LNG_BOUNDS,null);

        // configuration des buttons pour faire la recherche
        mSearchText.setAdapter(mplaceAutocompleteAdapter);
        mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener(){
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH
                || actionId == EditorInfo.IME_ACTION_DONE
                || keyEvent.getAction() == KeyEvent.ACTION_DOWN
                || keyEvent.getAction() == KeyEvent.KEYCODE_ENTER){
                    //execute our Method for searching
                    geoLocate();

                }

                return false;
            }
        });
        mgps.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG , "onClick  : clicked Gps icon");

                GetuserLocation();
            }
        });
        hideSoftKeyboard();
    }

0 个答案:

没有答案