0

I developing an Android app with multiple activities. Then i will create a button when it pressed its open Map Application (pre-installed on device / default map application) and the map application showing the driving route (from the current location to destination location). The question is :

  1. Its possible using other application (in this case Map Application) and launch it when pressed a button ?.

  2. If that possible, how i set the coding on my activity file ?, to showing direction on map from the current location to destination location (in this application i set my place).

  3. I Have googled the question, but i cant find. Can anyone give me the source or the tutorial (video, link) about my question ?.

UPDATE I've tried the same question like this Launching Google Maps Directions via an intent on Android ,but How to set from current location to known location ? is that possible ? :(

****PROBLEM RESOLVED** ** To open from my own app just use Intent implementation and to set from current location (automatic detected) to destination location (definition on intent) just lets plain/blank the source address, then force it open with google map (browser not allowed) because with browser, current location didnt work. Here the intent section i've used :

Uri.parse("http://maps.google.com/maps?saddr=&daddr=20.5666,45.345"‌​); 
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
Community
  • 1
  • 1
user2285197
  • 33
  • 2
  • 9

1 Answers1

0

You can do this. You need to launch the Maps activity with an Intent that contains the info that Maps needs. Here is a link to another SO question that will help.

Community
  • 1
  • 1
CaseyB
  • 24,780
  • 14
  • 77
  • 112
  • Oke i'll try, but in the question is show from location A to B with known coordinate. like `Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345")); startActivity(intent);`. My question is how to set from current location to destination location ? – user2285197 Jun 05 '13 at 15:36
  • You pass in where you are and where you want to go. You're going to need to look into the Maps Intent arguments to see how to pass that information. – CaseyB Jun 05 '13 at 17:11
  • So, its impossible to set "Current Location" on the intent ?. i need the app automatic show from current location to destination location when button pressed – user2285197 Jun 06 '13 at 02:19
  • Right, you would pass in where you want to go and then the user would choose where from. – CaseyB Jun 06 '13 at 14:09
  • 1
    Wow thanks! its work, just `plain the source addr` and to force directions to open with google map use `intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");`. Ppl with the same problem can try it. :) – user2285197 Jun 06 '13 at 16:42