views:

244

answers:

2

Hi all.

I am trying to get googlemaps to accept a local KML file.

final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=file://" + Environment.getExternalStorageDirectory() + "/locate.kml"));
startActivity(myIntent);

The file is on the SD card, and is a valid kml file. Googlemaps loads up, but says it cannot find the file.

final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=http://www.website.com/locate.kml"));
startActivity(myIntent);

Works fine. geo:0,0?q= seems to be very under documented, can anyone help me out with how to use it to refer to a local file?

A: 

JavaScript runs in a Sandbox, so it is not able to access local files without proprietary extensions.

henchman
This is on an Android device, not embedded in a web page.
arc
okay, sry. What is the value of Environment.getExternalStorageDirectory()?
henchman
/sdcardI am writing the file from another bit of code; File kmlfile = new File(Environment.getExternalStorageDirectory(), "locate.kml");And the intent does launch google maps, it just says "Not found file:///sdcard/locate.kml
arc
A: 

It seems it can't be done until Android 2.1

http://code.google.com/p/android/issues/detail?id=2454

arc