Software Development Kit

Answered

Trying to run the provided example for Android, but the addListener event is not working

 As per the sample example, when I add the add the addListener, it's not working and I'm unable to get the object being drawn. The code snippet I added is below:


 

 

final Editor editor = editorView.getEditor();
editor.addListener(new IEditorListener()
{
  @Override
  public void partChanging(Editor editor, ContentPart oldPart, ContentPart newPart)
  {
    // no-op

  }

  @Override
  public void partChanged(Editor editor)
  {

    invalidateOptionsMenu();
    invalidateIconButtons();
  }

  @Override
  public void contentChanged(Editor editor, String[] blockIds)
  {
    String text = editor.toString();
    Log.d("Content change : ",text);
    invalidateOptionsMenu();
    invalidateIconButtons();
  }

  @Override
  public void onError(Editor editor, String blockId, String message)
  {
    Log.e(TAG, "Failed to edit block \"" + blockId + "\"" + message);
  }
});

The logcat output is given here: https://drive.google.com/file/d/0B6NEGT8_-cLBRlBQVnhiZU9pa2VVVUFVU2FQazRMLUd3c2Fv/view?usp=sharing


We don't seem to be doing anything wrong. Let us know how we can solve it.

 


Best Answer

Dear Arnab,


thank you for contacting us and your question.


Looking at your code, I do not see anything wrong.


In the log, you have the "Didn't find class "android.view.View$OnUnhandledKeyEventListener"" message. Based on what I could found on the internet, this error seems to occur because of using an old version of Android studio, or a too old version of the ViewCompat class: https://stackoverflow.com/questions/51782548/androidxappcompat-iart-error-android-view-viewonunhandledkeyeventlistener/52136900


Best regards,


Olivier



Answer

Dear Arnab,


thank you for contacting us and your question.


Looking at your code, I do not see anything wrong.


In the log, you have the "Didn't find class "android.view.View$OnUnhandledKeyEventListener"" message. Based on what I could found on the internet, this error seems to occur because of using an old version of Android studio, or a too old version of the ViewCompat class: https://stackoverflow.com/questions/51782548/androidxappcompat-iart-error-android-view-viewonunhandledkeyeventlistener/52136900


Best regards,


Olivier


We were using version 7 but the example you linked has version 4. We will try using version 4 and report back if we are able to make it work. Thanks for your response.