Parcel write/read doesn't work in AndroidTestCase -why?

陌路散爱 提交于 2019-12-24 09:20:37

问题


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();

    }
}

回答1:


One must reset the Parcel's data position with: parcel.setDataPosition(0);



来源:https://stackoverflow.com/questions/22832403/parcel-write-read-doesnt-work-in-androidtestcase-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!