Start a new topic

onPoiDetailMoreButtonClicked not working

onPoiDetailMoreButtonClicked not working


I finally got it working! I forgot I was using fragments to load the camera view.

I had to override the ArchitectUrlListener inside the SampleCamFragment class, not only in SampleCamHandlePoiDetailActivity!

The original code inside SampleCamFragment does nothing:

public ArchitectUrlListener getUrlListener() {

return new ArchitectUrlListener() {

 

@Override

public boolean urlWasInvoked(String uriString) {

// by default: no action applied when url was invoked

return false;

}

};

}

 

It needs to be overriden as in the Activity:

 


public ArchitectUrlListener getUrlListener() {

return new ArchitectUrlListener() {

 

@Override

// fetch e.g. document.location = "architectsdk://markerselected?id=1";

public boolean urlWasInvoked(String uriString) {

Uri invokedUri = Uri.parse(uriString);

if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {

final Intent poiDetailIntent = new Intent(SampleCamHandlePoiDetailActivity.this, SamplePoiDetailActivity.class);

poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_ID, String.valueOf(invokedUri.getQueryParameter("id")) );

poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_TITILE, String.valueOf(invokedUri.getQueryParameter("title")) );

poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_DESCR, String.valueOf(invokedUri.getQueryParameter("description")) );

SampleCamHandlePoiDetailActivity.this.startActivity(poiDetailIntent);

return true;

}

return false;

}

};

}

 

That is all. Thanks for your help, Andreas!

 

please check that CamActivity inherits from "AbstractArchitectCamActivity", so 

@Override

public ArchitectUrlListener getUrlListener() {
...

}

is a valid annotation.

besides that, your code looks good.

 

Again, please check for difference between your sample and the official sample app, which appears to work without any issue. Also check for JS errors in your console  - maybe there is a JS syntax error or other exception happening.

 

Kind regards

This is what I have so far (which is not working at the moment):

public class CameraHandleIssueDetailActivity extends CameraActivity{

public ArchitectUrlListener getUrlListener() {
return new ArchitectUrlListener() {

@Override
// fetch e.g. document.location = "architectsdk://markerselected?id=1";
public boolean urlWasInvoked(String uriString) {
...

}
};
}

}

 

public class IssueDetailActivity extends Activity {

public static final String EXTRAS_KEY_POI_ID = "id";
public static final String EXTRAS_KEY_POI_TITILE = "title";
public static final String EXTRAS_KEY_POI_DESCR = "description";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.issue_detail);

((TextView)findViewById(R.id.poi_id)).setText( getIntent().getExtras().getString(EXTRAS_KEY_POI_ID) );
((TextView)findViewById(R.id.poi_title)).setText( getIntent().getExtras().getString(EXTRAS_KEY_POI_TITILE) );
((TextView)findViewById(R.id.poi_description)).setText( getIntent().getExtras().getString(EXTRAS_KEY_POI_DESCR) );
}

}

 

Is this correct? Should I add the url listener anythere else?

Thanks for your help.

Hi again.

Note that you have to register url listener inside the cam-experience to get notified. According your snippet you defined it inside the POI-Detail activity.
Please have a look at the "SampleCamHandlePoiDetailActivity.java" in the SDK Samples app, which calls "SamplePoiDetailActivity" after user pressed "more"-button.

Hope that helps,
Kind regards

Still no changes. My javascript code is the same as the example. In my Detail Activity class I have the following code:

 

public class MyPoiDetailActivity extends CameraActivity{

public ArchitectUrlListener getUrlListener() {

return new ArchitectUrlListener() {

 

@Override

// fetch e.g. document.location = "architectsdk://markerselected?id=1";

public boolean urlWasInvoked(String uriString) {

Uri invokedUri = Uri.parse(uriString);

if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {

final Intent poiDetailIntent = new Intent(CameraHandleIssueDetailActivity.this, IssueDetailActivity.class);

poiDetailIntent.putExtra(IssueDetailActivity.EXTRAS_KEY_POI_ID, String.valueOf(invokedUri.getQueryParameter("id")) );

poiDetailIntent.putExtra(IssueDetailActivity.EXTRAS_KEY_POI_TITILE, String.valueOf(invokedUri.getQueryParameter("title")) );

poiDetailIntent.putExtra(IssueDetailActivity.EXTRAS_KEY_POI_DESCR, String.valueOf(invokedUri.getQueryParameter("description")) );

CameraHandleIssueDetailActivity.this.startActivity(poiDetailIntent);

return true;

}

return false;

}

};

}

 

}

 

Should I have a look at something else?

Hi there!

Check out "onPoiDetailMoreButtonClicked" function in JavaScript. Calls like "document.location = "architectsdk://mynice?callback=true" will fire an event in your urlListener Implementation, compare Android Documentation of Native POI Detail Page.

Hope that helps.

Kind regards,
Andreas

Hi, I'm facing the same problem with the "More" button to display the POI detail in a new Activity. I've copied the Wikitude code to mi own application. This is the only feature that's not working. I've looked at the sample code many times but can't figure this out. I've already overriden the getUrlListener() method.

Am I missing something else?

Have you modified the example in anyway, or is this occuring with our unmodified SDKSamples application?

If you have copied the example into your own application you will need to register the ArchtiectURLListener in Java. (see SampleCamHandlePoiDetailActivity). If your Activity extends our AbstractArchitectCamActivity it is as simple as overriding the getUrlListener() method.

If you do not extend from the AbstractArchitectCamActivity, just make sure to call

// register valid urlListener in architectView, ensure this
// is set before content is loaded to not miss any event
this.architectView.registerUrlListener( yourUrlListener );

 

Hi Wikitude, 

I am running "example 5_BrowsingPois_5_NativeDetailScreen" and the "More" Button is doing anything (Wikitude 7.8.2 SDK 3.2 on Android 4.1.2 Samsung Galaxy S3)

About

// user clicked "More" button in POI-detail panel -> fire event to open native screen

onPoiDetailMoreButtonClicked: function onPoiDetailMoreButtonClickedFn() {

var currentMarker = World.currentMarker;

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

 

document.location = architectSdkUrl;

},

 

the architectSdkUrl is constructed fine but "document.location = architectSdkUrl" is not leading to architectSdkUrl.

 

Do you know why ?

 

BR,

Dimitrios

 

 
Login or Signup to post a comment