Overlay Map in the Background


Last Updated:

  1. idiot2k1

    idiot2k1 Member This Topic's Starter

    Joined:
    Mar 30, 2010
    Messages:
    8
    Likes Received:
    0
    Hello There,

    I am writing an app that will track the user via GPS and create a path on my MapActivity to show where they have been. The problem for me arises when the user navigates back to home to use other functionality of the phone.

    I am looking in my LogCat and it seems my process is dying when I access the Browser, for example. It ceases to work when I am driving and listening to music, but only after a period of time with no other action by me to break it.

    The way my MapActivity is set up has been with the launchMode of singleTask and singleInstance, both with the same error occurring. I am running a Runnable from the start of the MapActivity to take care of gathering the GPS location and placing a blip on the map, the runnable is also placed on a new Thread.

    Would there be an easier way to do this? Should I somehow create a Service that takes care of the location and blip functionality? How would I prevent the process from dying, and is there a way to see why it is being killed?

    (I was playing with Google Navigate, and I want similar functionality to how the GPS location and map state are saved, even when the user goes back to the home screen and messes with other applications.)

    Thanks for your help,
    -Adam
     

    Advertisement
  2. speedracer

    speedracer Member

    Joined:
    Nov 13, 2009
    Messages:
    5
    Likes Received:
    0
    yes, i would try to implement it as a Service. I would also suggest looking into AlarmManager and WakeLock to help prevent the CPU from going to sleep.

    check out this article for more info:
    Wake Up with the Alarm | AndroidGuys
     
  3. idiot2k1

    idiot2k1 Member This Topic's Starter

    Joined:
    Mar 30, 2010
    Messages:
    8
    Likes Received:
    0
    So I've been playing with my code and working on a few different ideas.

    I have my service running, and everything is fine.

    My question is how would I have my service affect the map activity that started it?
    Affect in the sense that the map would get an overlay based on the GPS info grabbed by the service.

    I have looked at AIDL and also broadcasting intents.

    Broadcasting looks like it would be closer to what I would want, but how can I have the map activity act as a listener for the intent.

    I can have the service get the GPS data, and my map activity is where the overlay is created, I just need to link the two together.

    Thanks Much
     

Share This Page

Loading...