Is it possible to convert a string that was created by Object.ToString() back to the original object i.e:
public boolean dispatchKeyEvent (KeyEvent event) {
appendLog(event.toString());
return super.dispatchKeyEvent(event);
}
appent log will log every keyevent as a string in a new line. After logging i would like to run the logged keyevents
Is it possible to convert the string logged keyevents to a KeyEvent object?
Only if the
toString()contains all the necessary event information. If it’s just a hash code, of course not. If the relevant info is available, you’d need to parse it, and use one of theKeyEventconstructors, and hope there’s nothing internally that isn’t reflected in thetoString. Seems sketchy to me.If you need to store it, it’s
Parcelable, that might help.You still have the event in the snippet you show, without an actual usecase it’s hard to know what you’re trying to do.