0

Im writing a custom program that uses a custom gps to track the users current position. I have a service running in the background that is constantly polling the GPS sensor for the current position. I then start a new activity with the following code:

final Intent intent = new Intent(Intent.ACTION_VIEW,
        Uri.parse(
            "http://maps.google.com/maps?" +
        "saddr="+lngstart+","+latstart+"&daddr="+lngend+","+latend));
         intent.setClassName(
          "com.google.android.apps.maps",
         "com.google.android.maps.MapsActivity");
           startActivity(intent);

The service running in the backgroud is constantly calculating new geopoints for the current location of the user. The google maps comes up as intented, and has the data I fed it initially, however Id like to constantly feed it updated information on the users current position.

How do I feed this updated information about the users current location to the map activity I've started?

How do I disable the map activity from trying to use any other sensor (like cell phone towers, or using built in GPS, remember Im using a custom gps setup)?

How do I ping the running activity to get the list information containing the longitude and latitude coords of the "legs" along the route that it plots?

Finally is there a way to add a button to the running activity, that when pressed will pause it, and start a new activity?

Thanks :)

The Starfox
  • 101
  • 1
  • 1
  • 4

2 Answers2

0

When you are sending this Intent you basically moving to a new application, a Google Maps application that sits in you Android phone. AFAIK you don't have any control over this application as this is not part of your app and at this point you can't manipulate it. So you can't add any buttons to it or disable any sensors it might be using for it's navigation (unless you disable them from the settings.)

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • I thought you could manipulate it based on the settings you send in the string values? Any place that explains all the functions of the maps intent? – The Starfox Apr 09 '13 at 19:03
  • best choice would be: http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android – Emil Adz Apr 09 '13 at 19:09
  • When you open the activity we can pass necessary parameters and Google Map will load the map based on the parameters. But once it is loaded you cannot control it from your application. – Joseph Selvaraj Apr 09 '13 at 19:11
  • you are exactly right. to add all your desired functionality you would have to develop your own directions application (maybe using Google Maps API: https://developers.google.com/maps/documentation/android/intro) – Emil Adz Apr 09 '13 at 19:12
  • I do have a service running in the background even when the google maps start. So there is no way to say use an intent.getData() or something like that, to extract any data from the application? – The Starfox Apr 09 '13 at 19:50
  • you have to understand, when you fire this intent you quitting the scope of your application and moving to another one. You have not control over this application (beside the possibility to start it with a specific parameters for navigation purposes). So you service can't interact with it. – Emil Adz Apr 09 '13 at 19:53
  • Alight then. Looks like I'll have to write a map activity then. Whats the best resource to make an application that can do what I was asking above? – The Starfox Apr 09 '13 at 20:38
  • you can start with this blog post I wrote on how to integrate google map into your application: http://blog-emildesign.rhcloud.com/?p=435 but adding directions capabilities to it is a whole lot another story. – Emil Adz Apr 09 '13 at 20:43
0

My thoughts on your questions:

How do I feed this updated information about the users current location to the map activity I've started?

Once you have started the google map activity, you cannot control it again from your application. Only option is to recreate the google map intent with new location.

How do I disable the map activity from trying to use any other sensor (like cell phone towers, or using built in GPS, remember Im using a custom gps setup)?

If you are using Google Map API then may be you can control that. But I have never tried it. But if you are invoking existing map application like above then I dont think you have any control

How do I ping the running activity to get the list information containing the longitude and latitude coords of the "legs" along the route that it plots?

Not Sure about this request. May be you can save the initial location and get the current location. Then use those two locations and create the map

Finally is there a way to add a button to the running activity, that when pressed will pause it, and start a new activity?

You can do that using Google Map API and not using google intent.

Joseph Selvaraj
  • 2,225
  • 1
  • 21
  • 21