Application Tool Kit

App crashing after executing CandidateInfo's delete() method


I'm developping a HWR app for Android using the MyScript ATK2.2. I've been testing it using an Android Studio Virtual Device (Nexus 9 tablet, Android 6.0 (API 23)).

I've been dealing with the CandidateInfo class for a while (as I posted in another thread before). While trying to learn more about this, at one point I executed the CandidateInfo#delete() method. From there on the ATK won't give me any more candidate info. SingleLineWidgetApi#getWordCandidates() returns a CandidateInfo object, but since that fatal delete(), it doesn't contain any useful information any more (i.e. getSize() would always return 0, getSelectedLabel() and getSelectedSource() would both return "", getStart() and getEnd() would both return -1 and so on).

I tried to figure out, what might have been deleted (searching filesystem for files modified within the relevant time), but wasn't able to determine, what it might be. I can only guess, that any link to a resource or part of a resource is missing (since getSelectedSource() returns "", whereas it used to return some String looking like a file name (ending with .lex,if I remember correctly)). But I just don't know, how to put that thing back into place.

Trying some simple repair moves, I've deleted and re-applied all resource files I use. I've also replaced the ATK .aar-files with fresh ones. I've cleared the Android Studio build cache, cleaned and rebuilt the gradle project, uninstalled the Android Virtual Device and created a new one, everything with obviously no effect.

So, I've no idea where else to look for the problem's cause. I'd appreciate any help, e.g. information about what the delete() method actually does... ;)

Thank you very much!

Dear Axel,

thank you for your questions.

Currently, the delete function is only to remove the content of the CandidateInfo object.

I cannot figure out what is likely to have occurred on your side, as only the result should have been cleaned.. Did there have any change in your project?

Best regards,

Dear Olivier,
thank you for that hint and sorry for my confusion. I managed to fix it. In deed the problem was caused by two bugs inside my code, that I applied just before I executed delete(). Only trying to give this thread a single bit of value, I'm quickly describing one of my bugs: What caused the returned CandidateInfo object not to contain any content was that I did:



This was the result of placing the cursor behind the last word and then using getCursorIndex() to receive the word candidate. So in fact I didn't really select any word (highest useful value would have been the index of the last character (which in my case is equal to getCursorIndex()-1)) and thus the CandidateInfo was empty.

Kind regards,


Login or Signup to post a comment