Start a new topic
Solved

UrlListener Android Help

I am a little confused as to how the registerUrlListener and urlWasInvoked  methods work? I have look through the examples and read the sdk documentation, but i still don't quite understand.


So in the javascript lets say you do :


 var architectSdkUrl = "architectsdk://markerselected?

document.location = architectSdkUrl


Then if i am correct you just need to register the Url MarkerSelected? Which gives you something like this below? Honestly Any help would be much appreciated.


public void registerUrlListener (ArchitectView.ArchitectUrlListener markerselected){
@Override
public boolean urlWasInvoked(String arg0){

return false;
}});
}
1 Comment

Hi Ashley,


Here is an example where the document location is 

 

var location = "architectsdk://markerselected?id=" +
			encodeURIComponent(currentMarker.poiData.id) + 
			"&title=" + 
			encodeURIComponent(currentMarker.poiData.title) + 
			"&description=" + 
			encodeURIComponent(currentMarker.poiData.description);

 

the java code to handle it looks like this:

   

ArchitectUrlListener urlListener = new ArchitectUrlListener() {
	@Override
	public boolean urlWasInvoked(String uriString) {
		Uri invokedUri = Uri.parse(uriString);
				
		// pressed "More" button on POI-detail panel
		if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
			String id = String.valueOf(invokedUri.getQueryParameter("id"));
			String title = String.valueOf(invokedUri.getQueryParameter("title"));			
			String description = String.valueOf(invokedUri.getQueryParameter("description"));

			// do something with id, title, description			

			return true;
		}
		return true;
	}
});

// should be done in onCreate
architectView.registerArchitectUrlListener(urlListener);

 

There is also a new API for JS->Java connections, which is easier to use, coming in the next release which deprecates the document.location API. The release will be available in this week.


Best Regards,

Alex

Login or Signup to post a comment