John
John

Reputation: 33

Java - How to navigate to a map url in android studio?

I have a button that navigates to the map with a certain link. Here is my code:

Intent open2 = new Intent(android.content.Intent.ACTION_VIEW);

open2.setData(Uri.parse("https://www.google.com.eg/maps/dir/''/point+90+mall+location/data=!4m5!4m4!1m0!1m2!1m1!1s0x145822591a17706b:0xc9f886adcffbb941?sa=X&ved=0ahUKEwiF5-KS6t3SAhWoLcAKHWI-CEoQ9RcIeTAM"));

startActivity(open2);

But when I click from my mobile, it goes to the map. But it gives this to me:

Cannot find the starting point

How can I fix that?

Upvotes: 0

Views: 2252

Answers (1)

stamanuel
stamanuel

Reputation: 3809

You are using the wrong maps query-string, try this:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?q=Point 90 Mall, Cairo Governorate"));
startActivity(intent);

Generally use this query http://maps.google.com/maps?q=PLACE_NAME where you replace the PLACE_NAME with the place name (or search string) of google maps.

More info here: https://developers.google.com/maps/documentation/android-api/intents

and here: open google maps through intent for specific location in android

Upvotes: 1

Related Questions