Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 20
Registered: ‎10-29-2009
My Device: Not Specified

Runtime Exception when trying to open Google Maps from my app

I am trying the following code to start google maps with a landmark I pass to it:

 

 

public void run(){
		Locator l = new Locator();
		Dialog.alert("L: " + l.toString());
		QualifiedCoordinates coord = l.getCoord();
		int mh = CodeModuleManager.getModuleHandle("Google Maps");
		if (mh == 0) {
		     Dialog.alert("GoogleMaps isn't installed");
		}
		URLEncodedPostData uepd = new URLEncodedPostData(null, false);
		uepd.append("action","LOCN");
		uepd.append("a", "@latlon:"+ coord.getLatitude()+","+ coord.getLongitude());
		uepd.append("title", "Lansdown Road, Dublin");
		uepd.append("description", "Desc");
		String[] args = { "http://gmm/x?"+uepd.toString() };
		ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
		ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
		try {
			ApplicationManager.getApplicationManager().runApplication(ad2, true);
		} catch (ApplicationManagerException e) {
			e.printStackTrace();
		}
	}

 

 

 

It throws a Runtime exception. I am only testing on a simulator at the moment. RIM component package 4.7.0 on the Blackberry 9530. I have google maps installed on the simulator.  Should I have any particular cod, etc, files stored in the simulators directory? Any help would be appreciated.

Developer
Posts: 109
Registered: ‎12-04-2008
My Device: Playbook, Torch 9800, Storm 9530, Tour 9630
My Carrier: Telus

Re: Runtime Exception when trying to open Google Maps from my app

I'm not sure it matters but I use a Location and retreive the lat/long like this: location.getQualifiedCoordinates().getLongitude()

I also like to see the error message it's throwing so in the catch I use something like System.out.println(ApplicationManagerException error: " + e.getMessage();  instead of printStackTrace()

Might help narrow things down...

PlayBook Apps: Sudoku Pro
Smartphone Apps: Compass | MultiClock
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Runtime Exception when trying to open Google Maps from my app

What exception is thrown?

 

At what line of code?

 

Highlighted
Developer
Posts: 87
Registered: ‎07-23-2009
My Device: Z30
My Carrier: XL

Re: Runtime Exception when trying to open Google Maps from my app

[ Edited ]

may be  it is because you call the wrong  module name, you must use like this

 

int mh = CodeModuleManager.getModuleHandle("GoogleMaps");

 not like this (with white space)

 

int mh = CodeModuleManager.getModuleHandle("Google Maps");

 

 

 

Developer
Posts: 20
Registered: ‎10-29-2009
My Device: Not Specified

Re: Runtime Exception when trying to open Google Maps from my app

 

Thanks for the replies, the runtime exception occured as I did not call the class correctly, once I used:

 

public void showGoogleMaps(){
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new GoogleMap());
            }
        });
    }

 

it was functioning fine.

 

 

was also correct, as the above module name was incorrect. Needed to be GoogleMaps.

On another note has anyone ever figured out how to open google maps with multiple locations, ie POIs.

I was pleased to find out that you can point the browser to a url with a kml file and as long as you have google maps installed it will open up the kml file. I am still looking into this as I would prefer to have the files stored localy on the phone and point the browser to the file, but it does not know what to do with it unlike when it recieves the file from a server. Has anyone had any luck with google maps in this way?
Developer
Posts: 78
Registered: ‎12-03-2009
My Device: Not Specified

Re: Runtime Exception when trying to open Google Maps from my app

"I was pleased to find out that you can point the browser to a url with a kml file and as long as you have google maps installed it will open up the kml file. I am still looking into this as I would prefer to have the files stored localy on the phone and point the browser to the file, but it does not know what to do with it unlike when it recieves the file from a server. Has anyone had any luck with google maps in this way?"

 

Does anybody figure out some thing?

Thanks!

--
Feel free to press the kudos button on the left side to thank the user that helped you.
Please mark posts as solved if you found a solution.