Yes, I have done plenty of this now. Here's how I do it: My Parcelable is called an OnlineUser. Here's the important stuff:
private OnlineUser(Parcel in) { readFromParcel(in); } public void writeToParcel(Parcel out, int arg1) { writeToParcel(out); } public void writeToParcel(Parcel out) { out.writeInt(id); out.writeString(userName); out.writeString(dictionary); out.writeInt(allowRandomGames ? 1 : 0); } public void readFromParcel(Parcel in) { id = in.readInt(); userName = in.readString(); dictionary = in.readString(); allowRandomGames = in.readInt() == 1; } public int describeContents() { return 0; } public static final Parcelable.Creator<OnlineUser> CREATOR = new Parcelable.Creator<OnlineUser>() { public OnlineUser createFromParcel(Parcel in) { return new OnlineUser(in); } public OnlineUser[] newArray(int size) { return new OnlineUser[size]; } }; On Sep 23, 9:52 am, Ne0 <liamjamesalf...@googlemail.com> wrote: > Has anyone had experience with passing a pacelable class through an > aidl interface? > > Just cant get it to work the way they describe > herehttp://developer.android.com/guide/developing/tools/aidl.html#impleme... > > cheers, > > Liam > > On Sep 23, 10:59 am, Ne0 <liamjamesalf...@googlemail.com> wrote: > > > Been using remote interfaces for quite a while now, but the time has > > come to increase the amount of data i need to pass between processes. > > Following the Designing a Remote Interface using aidl examples/ > > tutorial i have had some success but have now come to a problem. > > > My activity binds to my service no problem, the callbacks work, but > > the data i send does not reach the client. My code is an extension of > > "Pass by value Parameters using Parcelables" from the "Designing a > > Remote Interface using aidl" page. The only difference is the amount > > of data, it has 18 int's and 3 Doubles. As you will see below, once i > > have entered the data into the parcel, i create my Parcelable > > using .createFromParcel(p) this however does not seem to work, even > > when my Parcelable is reading from the parcel no data gets read. > > > Here is my code for sending the data to the client. > > > /* > > * Send the latest info to the bound apps > > */ > > private void updateBoundApps(){ > > > if(mCallbacks.beginBroadcast() > 0){ > > if(gLOG){Log.d(TAG,"updateBoundApps " + mSMNI.int1);} // > > Always > > shows int1 as corret value (non 0) > > > Parcel p = Parcel.obtain(); > > p.writeInt(mSMNI.int1); > > p.writeInt(mSMNI.int2); > > p.writeInt(mSMNI.int3); > > p.writeInt(mSMNI.int4); > > p.writeInt(mSMNI.int5); > > p.writeInt(mSMNI.int6); > > > Iterator<Entry<Object, Object>> itNew = > > mSMNI.intMap.entrySet > > ().iterator(); > > for(int i = 0 ; i < 6; i++){ > > if(itNew.hasNext()){ > > Map.Entry<Object, Object> eNew = > > itNew.next(); > > p.writeInt((Integer) eNew.getKey()); > > p.writeInt((Integer) eNew.getValue()); > > }else{ > > p.writeInt(0); > > p.writeInt(0); > > } > > } > > p.writeDouble(mLastLoc.Double1); > > p.writeDouble(mLastLoc.Double2); > > p.writeDouble(mLastLoc.Double3); > > > MPSData mpsd = MPSData.CREATOR.createFromParcel(p); > > // Send the message > > Message msg = mHandler.obtainMessage(REPORT_MSG, mpsd); > > mHandler.sendMessageDelayed(msg, 1*1000); > > p.recycle(); > > } > > mCallbacks.finishBroadcast(); > > } > > > Here is my Parecelable: > > > public class MPSData implements Parcelable{ > > > public int int1; > > public int int2; > > public int int3; > > public int int4; > > public int int5; > > public int int6; > > public int int7; > > public int int8; > > public int int9; > > public int int10; > > public int int11; > > public int int12; > > public int int13; > > public int int14; > > public int int15; > > public int int16; > > public int int17; > > public int int18; > > public double double1; > > public double double2; > > public double double3; > > > public static final Parcelable.Creator<MPSData> CREATOR = new > > Parcelable.Creator<MPSData>() { > > @Override > > public MPSData createFromParcel(Parcel in) { > > Log.d("MPSData","createFromParcel dataAvail " + > > in.dataAvail() + " > > dataSize " + in.dataSize()); > > return new MPSData(in); > > } > > > public MPSData[] newArray(int size) { > > return new MPSData[size]; > > } > > }; > > > public MPSData(){ > > > } > > > private MPSData(Parcel in){ > > Log.d("MPSData","MPSData(Parcel in)"); > > readFromParcel(in); > > } > > > @Override > > public int describeContents() { > > // TODO Auto-generated method stub > > return 0; > > } > > > public void writeToParcel(Parcel out) { > > out.writeInt(int1); > > out.writeInt(int2); > > out.writeInt(int3); > > out.writeInt(int4); > > out.writeInt(int5); > > out.writeInt(int6); > > out.writeInt(int7); > > out.writeInt(int8); > > out.writeInt(int9); > > out.writeInt(int10); > > out.writeInt(int11); > > out.writeInt(int12); > > out.writeInt(int13); > > out.writeInt(int14); > > out.writeInt(int15); > > out.writeInt(int16); > > out.writeInt(int17); > > out.writeInt(int18); > > out.writeDouble(double1); > > out.writeDouble(double2); > > out.writeDouble(double3); > > } > > > public void readFromParcel(Parcel in) { > > int1= in.readInt(); > > Log.d("MPSData","readFromParcel(Parcel in) " + int1); // > > Always > > shows int1 as 0 > > int2= in.readInt(); > > int3= in.readInt(); > > int4= in.readInt(); > > int5= in.readInt(); > > int6= in.readInt(); > > int7= in.readInt(); > > int8= in.readInt(); > > int9= in.readInt(); > > int10= in.readInt(); > > int11= in.readInt(); > > int12= in.readInt(); > > int13= in.readInt(); > > int14= in.readInt(); > > int15= in.readInt(); > > int16= in.readInt(); > > int17= in.readInt(); > > int18= in.readInt(); > > double1= in.readDouble(); > > double2 = in.readDouble(); > > double3 = in.readDouble(); > > } > > > @Override > > public void writeToParcel(Parcel dest, int flags) { > > // TODO Auto-generated method stub > > > } > > > } > > > Thanks for any help; > > > Liam > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---