I want to pass a Runnable into an activity via bundle, so that runnable must run when onCreate fires. I wrote a class which implements Serializable but it causes exception: "java.lang.RuntimeException: Parcelable encountered IOException writing serializable object"
.
My code goes here:
package some.company.common;
import java.io.Serializable;
public class SerializedRunnable implements Serializable, Runnable {
private static final long serialVersionUID = 6641813629033240205L;
public SerializedRunnable() {
}
private Runnable runnable;
public SerializedRunnable(Runnable runnable) {
this.runnable = runnable;
}
@Override
public void run() {
this.runnable.run();
}
}