General questions

Restore String on Widget

Hi Support,

I have a question, when a recognition session ends It returns the widget in which I could easily extract the result in string by using widget.getResultAsText() but I want to restore this result on widget In edit mode, When I come back on this screen. Need help in this case.


Do you have any other specific question?

Hi cate,

Are you there?

Sorry for the delay,
Actually there is no specific api at the MathWidget level to achieve this. However, it should be possible to manage views, so the exported result as Image appears in front of MathWidget Writing area.

Best regards

Hi cate,

I am waiting for your response.


Hi Cate,

Yeah, You are right. One thing more, Can I open MathWidget view in Read Only mode? means user wou;dn't be able to write the equation just he would be able to see his last entered equation. Kindly help plz.

Best Regards

It is not possible unfortunately. Only the AddSymbol api will enable you to add symbol in the MathWidget view, but it requires that those symbols have to be previously recognized by the MathWidget.

To better understand your needs, does it mean that you are able to input symbols or equations with your math keyboard that you are unable to get with our MathWidget?

Best regards

Hi Cate,

Thanks for your respond. Yeah , This method have done for me. One thing more, I have an input area on screen where user will write equation through math keyboard. I want to load that string from edittext into Mathwidget view? How can I done this? Kindly help plz.


Would it be interesting for you to use
'Bitmap b = mWidget.getResultAsImage();'
to show only the recognition result?

Otherwise, in which part of your code have you added the snippet to create a screenshot, it seems related to the view, so if you want to export the recognition result, it should be displayed on this view as well.

Hope it helps.
Best regards

Hi cate,

Can you please help me in this issue.


Here's the difference.

Screenshot taken from Device native button

Screenshot taken Programmatically by using above code which I posted.

Hi cate,

Thanks for your kind respond. I have one more issue which I am facing in MyScript.

I need to show the screenshot of the MyScript widget view in app. After user have finished with the equation writing process he press the done button and app takes the screenshot of the view but when I see the screenshot its doesn't show the equation in the screenshot but Screenshot shows other screen elements.

For Taking screenshot, I am using this code.
final String[] base64 = {};
View v1 = view;
Bitmap b = Bitmap.createBitmap(v1.getDrawingCache());
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOS);
base64[0] = Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT);

Ok thanks for those details, you will have to store the byte array in order to be able to restore the equation in the MathWidget. Regarding your use case, it seems logical to store a couple (string,byte array) in your database for each record, then you will be able to restore a byte array (only compatible format with 'Unserialize') for a specific string.

Hope it helps.

I want to store data as a string in local database. and when user re visit that screen , it will show the previous data first to the user thats y I want to store data as a string rather than byte . Can you help me plz?

Dear Ahsan,
Were you able to move forward on this?

Regarding your code, you should be able to serialize and unserialize this way:

 byte[] serializeResult;
serializeResult = mWidget.serialize();

//wait before unserialize
if (mWidget.unserialize(serializeResult) == false) {
Log.d(TAG, "Unserialization failed");

I am not sure to understand why you need to convert it to a string actually. Could you please send us an update and let us know if you face any issue?
Best regards

Dear Ahsan,
I think the following post about serialize/unserialize MathWidget ATK1.3 may interest you:

The ATK2.0 version of MathWidget includes a change for unserialize api:
boolean unserialize(byte[] data)
Restore an input and recognition result saved using serialize method.
data - the byte array to unserialize, provided by #serialize.
true on success, false otherwise.

Please let us know if it helps
Best regards

Login or Signup to post a comment