0

I am trying to open Google Maps(for turn-by-turn navigation) inside a class that extends "service" instead of activity. The code I got from the google developer guide as below works fine with activity, but not service. I really need to open Google Maps from my app that stays in the background. Can somebody help me?

Uri gmmIntentUri = Uri.parse("geo:0,0?q=-33.8666,151.1957(Google+Sydney)");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

Trying to use the above code inside:

public class myClass extends Service {
   ...
}
  • 1
    "The code I got from the google developer guide as below works fine with activity, but not service" -- please explain **in detail** what your problem is. At minimum, you are missing `FLAG_ACTIVITY_NEW_TASK` on `mapIntent`. – CommonsWare Jun 20 '17 at 20:15
  • Adding the flag solved it. Thank you! :) If you want to leave an answer, I'll choose it! – A. Servi Jun 20 '17 at 20:56

0 Answers0