tags:

views:

46

answers:

1

Hey Everyone,

I am trying to overlay route data in KML files on a MapView. The following code works great:

Intent mapIntent = new Intent(Intent.ACTION_VIEW);
Uri uri1 = Uri.parse("geo:0,0?q=http://code.google.com/apis/kml/ 
documentation/KML_Samples.kml");
mapIntent.setData(uri1);
startActivity(Intent.createChooser(mapIntent, "Test"));

The only problem I have with this is that I don't need to re download these KML files every time. I have about 10-15 KML files that will rarely change. Also since it has to connect, download, and parse these each time there is a delay in opening the maps.

It would make a lot more since for me to save these as a local resource and have the URI reference it there. Is there a way to construct a URI using the geo: scheme and have it point towards a local resource?

Thanks, Rob

EDIT: It looks like file:///sdcard support was included in 2.1. The only reference I could find to it was at the end of this bug report thread. I am currently at work and don't have time to play with this yet but I would like to figure it out later. I feel like there are a lot of people on stackoverflow and elsewhere who would really appreciate a reasonable way to do this.

A: 

You could try a file:///sdcard URL, where /sdcard is what Environment.getExternalStorageDirectory() returns you. Whatever it is, it has to be world-readable, since the Maps application is not your application.

CommonsWare
@CommonsWare: Do you know of any good resources for learning about using this? Perhaps in one of your books?
Tarmon
@Tarmon: What part of the question or answer is the "this" for which you want "good resources for learning"?
CommonsWare
@CommonsWare: I apologize for being vague, I should put more thought into my requests. I was thinking of any resources regarding using file:// URLs or anything regarding external storage. Thanks again. You have responded to a lot of my posts on here and I really appreciate it. With out the background in programming I probably need, a lot of this SDK has left be baffled.
Tarmon
@Tarmon: Well, I cover a bit about external storage in _The Busy Coder's Guide to Android Development_ (via subscription, or in print as _Beginning Android 2_). I do not believe I cover `file://` URLs specifically, though.
CommonsWare