我正在尝试在我的程序中实现以下结构:
public abstract class A extends Service {
public abstract void getData();
//variables
public int onStartCommand(Intent intent, int flags, int startId) {
mHandler.postDelayed(1*1000, mHandler);
return START_STICKY;
}
public Runnable runnable = new Runnable() {
public void run() {
AnotherClass ac = new AnotherClass();
ac.method();
// AnotherClass implements Serializable and stores all data.
A start = new B();
//Start abstract method getData defined in class B
start.getData();
mHandler.postDelayed(runnable, 1 * 1000);
}
};
}
现在B是一个扩展A的类。
public class B extends A {
public void getData() {
//Here I need to fetch the data from ac(AnotherClass) object which was serialized.
//perform my activity.
}
}
我是这个可序列化概念的新手。我可以用它来实现上面的结构吗?另外,我可以将ac对象的内容序列化为矢量吗?请指导我,一个例子会非常有帮助。