包裹写入/读取在 AndroidTestCase 中不起作用 - 为什么? [英] Parcel write/read doesn't work in AndroidTestCase -why?
本文介绍了包裹写入/读取在 AndroidTestCase 中不起作用 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试测试以在 Android 测试中写入包裹,但它不起作用.s==空!怎么了?
I am trying to test to write to a Parcel in Android test but it doesnt't work. s==null! What is wrong?
public class scraptest extends AndroidTestCase {
public void test() {
Parcel parcel=Parcel.obtain();
parcel.writeString("sdfsdf");
String s=parcel.readString();
}
}
推荐答案
必须使用以下命令重置 Parcel 的数据位置:包裹.setDataPosition(0);
One must reset the Parcel's data position with: parcel.setDataPosition(0);
这篇关于包裹写入/读取在 AndroidTestCase 中不起作用 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文