Start a new topic
Solved

unable to pass json to native code

HI Team


I am getting below message in monitor if i clicked a button in javascript to send json to native code.


05-29 20:28:09.302 24419-24419/com.example.santhosh.onboardar W/cr_Ime: updateState: type [0->0], flags [0], show [false],

05-29 20:28:09.340 24419-24532/com.example.santhosh.onboardar W/CallbackHandler: forwardJSONObject: There are no ArchitectJavaScriptInterfaceListener set.

                                                                                 Use architectView.addArchitectJavaScriptInterfaceListener to receive the data.


I have implemented ArchitectJavaScriptInterfaceListener in native code as below:


public class MainActivity extends AppCompatActivity implements ArchitectJavaScriptInterfaceListener{
.....


@Override
public void onJSONObjectReceived(JSONObject jsonObject) {
try{
switch (jsonObject.getString("name")) {
case "facebook":
final Intent poiDetailIntent = new Intent(MainActivity.this, imageViewer.class);
poiDetailIntent.putExtra(imageViewer.EXTRAS_KEY_POI_ID, jsonObject.getString("id"));
MainActivity.this.startActivity(poiDetailIntent);
break;
}
}

catch (JSONException e) {
Log.e(TAG, "onJSONObjectReceived: ", e);
}
} Please help me in getting JSON object passed from JS to native code and let us know if i am missing something in above code. Thanks

Hello Santhosh,

Could you please provide with some further details on the issue:
  • Which version of the SDK are you using?
  • Are you using the JS API?
  • Are you using any of our Extensions (Titanium, Cordova, Xamarin, Unity)? If yes, which version are you using?

Also, please refer to this link to see how you can send a json object to a platform.


Thanks

Eva

HI Eva,


I am using Wikitude SDK version: 6.1.0 and JS api.

not using any extensions. I am using android studio.


I am getting warning like Below:

05-29 20:28:09.302 24419-24419/com.example.santhosh.onboardar W/cr_Ime: updateState: type [0->0], flags [0], show [false],

05-29 20:28:09.340 24419-24532/com.example.santhosh.onboardar W/CallbackHandler: forwardJSONObject: There are no ArchitectJavaScriptInterfaceListener set.

                                                                                 Use architectView.addArchitectJavaScriptInterfaceListener to receive the data.


Please help me in how to use architectView.addArchitectJavaScriptInterfaceListener to receive the data.


Thanks


Hi


your code to use the ArchitectView should look similar to this:

   

architectView = (ArchitectView)this.findViewById( this.getArchitectViewId()  );
        
final ArchitectStartupConfiguration config = new ArchitectStartupConfiguration();
config.setLicenseKey( KEY );

architectView.onCreate( config );

 

To enable receiving data from JavaScript you have to add the following line after architectView.onCreate

   

architectView.addArchitectJavaScriptInterfaceListener(this); // this refers to the MainActivity implementing the ArchitectJavaScriptInterfaceListener

  

Best Regards,

Alex 

Thanks Alex. Its working. :)

Login or Signup to post a comment