블로그 이미지
인간은 자신이 이해하지 못하는 것을 경멸하는 버릇이 있다. 셜병장

카테고리

분류 전체보기 (37)
주절주절 (1)
누리다 (1)
생활의 발견 (0)
Memory (1)
내 몸의 물 (8)
Developments (14)
Android (8)
Java (5)
JavaScript/Html (1)
Window (0)
Tool (0)
Attraction (9)
Soccer&Futsal (4)
Wellness (1)
Interests (4)
Father Time (2)
Play Ground (1)
Total
Today
Yesterday

[Android] Parcel

Developments/Android / 2013. 7. 13. 11:29

Parcel은 내부의 데이터는 모두 직렬화 되어야한다.

parcel로 저장된 데이터는 Serializable되었으므로 Read시 순서대로 읽어야 한다.

(setDataPosition을 통해 특정 위치로 이동할수 있다.)


Parcel parcel = parcel.obtain();

// write -->

parcel.writeInt(intData);

parcel.writeString(stringData);

parcel.writeFloat(floatData);


parcel.setDataPosition(0);


//read -->

parcel.readInt();

parcel.readString();

parcel.readFloat();


Serializeable을 상속받은 객체


String

ArrayList

LinkedList

HashMap

TreeMap


implements된 Parcelable에 상속받는 method

describeContents() 


writeToParcel(Parcel out, int flags)  //객체 분해 송신시 사용

해당 객체 전송하면 frameworks 내부의 IPC 전송담당에서 자동으로 호출한다.


//객체 조립 수신시

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public static final Parcelable.Creator<SearchRequest> CREATOR
 
        = new Parcelable.Creator<SearchRequest>() {
 
    public testPacel createFromParcel(Parcel in) {
 
        return new SearchRequestImpl(in);
 
    }
 
 
 
    public testPacel[] newArray(int size) {
 
        return new testPacel[size];
 
    }
 
};


Posted by 셜병장
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함