0

I am trying to get directions in an app, but I keep getting a REQUEST_DENIED, I am using the library mentioned in this answer (And here is the repo)

I have the API key and I am using it like this:

GoogleDirection.withServerKey(getString(R.strings.google_maps_key))
    .from(new LatLng(40.2085, -3.7136))
    .to(new LatLng(mCoord[0], mCoord[1]))
    .avoid(AvoidType.FERRIES)
    .avoid(AvoidType.HIGHWAYS)
    .execute(new DirectionCallback() {
            @Override
            public void onDirectionSuccess(Direction direction) {
                if (direction.isOK()) {
                    Toast.makeText(getApplicationContext(), "DIRECTION KOK", Toast.LENGTH_LONG).show();
                    //                            direction.
                } else {
                    Toast.makeText(getApplicationContext(), direction.getStatus(), Toast.LENGTH_LONG).show();
                }
            }

            @Override
            public void onDirectionFailure(Throwable t) {
                Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_LONG).show();
            }
        });

I don't have any clue of what is failing.

Community
  • 1
  • 1
Alejandro Alcalde
  • 5,990
  • 6
  • 39
  • 79

1 Answers1

1

I found the problem. It is the first time I am using the google console developer, I thought I only needed the API key.

It turns out you have to activate the Google Direction API.

Now the request is correct.

Alejandro Alcalde
  • 5,990
  • 6
  • 39
  • 79