###前提・実現したいこと
Androidのaidlで二つ目のParcelableのデータがnullになる
バインドしたServiceに対してデータを送りたいのですが、postMessageメソッドの二つ目の引数であるMessageオブジェクトに格納されているメンバー変数のStringのみが初期化(null)が入る事象がまれに起こって困っています。
aidlの書き方を変えてみたのですが、ちょっと混乱しています
###試したこと
aidlのonewayのあるなし、引数のinout , in , outを変更して試した。
いずれもうまく機能しない
###aidl
GroupとMessageはParcelableを継承
aidl
1oneway void postMessage(inout Group group, inout Message message);
###Message
GroupとMessageはParcelableを継承
Java
1public class Message implements Parcelable, Cloneable { 2 3 public Message() { 4 } 5 6 @Override 7 public Message clone() { 8 try { 9 return (Message) super.clone(); 10 } catch (CloneNotSupportedException e) { 11 e.printStackTrace(); 12 } 13 return null; 14 } 15 16 @SerializedName("id") 17 private long messageId; 18 @SerializedName("personId") 19 private String fromPersonId; 20 private String userName; 21 @SerializedName("iconUrl") 22 private String userImage; 23 @SerializedName("message") 24 private String messageText; 25 private String messageImage; 26 private String messageAudio; 27 private String messageVideo; 28 @SerializedName("to") 29 private String toPersonId; 30 private String toPersonIcon; 31 private String toPersonName; 32 @SerializedName("postDate") 33 private long publishDate; 34 private long receiveDate; 35 36///省略Getter And Setter 37 38 @Override 39 public int describeContents() { 40 return 0; 41 } 42 43 @Override 44 public void writeToParcel(Parcel dest, int flags) { 45 dest.writeLong(this.messageId); 46 dest.writeString(this.fromPersonId); 47 dest.writeString(this.userName); 48 dest.writeString(this.userImage); 49 dest.writeString(this.messageText); 50 dest.writeString(this.messageImage); 51 dest.writeString(this.messageAudio); 52 dest.writeString(this.messageVideo); 53 dest.writeLong(this.publishDate); 54 dest.writeLong(this.receiveDate); 55 dest.writeString(this.toPersonId); 56 dest.writeString(this.toPersonIcon); 57 dest.writeString(this.toPersonName); 58 } 59 60 public void readFromParcel(Parcel in) { 61 this.messageId = in.readLong(); 62 this.fromPersonId = in.readString(); 63 this.userName = in.readString(); 64 this.userImage = in.readString(); 65 this.messageText = in.readString(); 66 this.messageImage = in.readString(); 67 this.messageAudio = in.readString(); 68 this.messageVideo = in.readString(); 69 this.publishDate = in.readLong(); 70 this.receiveDate = in.readLong(); 71 this.toPersonId = in.readString(); 72 this.toPersonIcon = in.readString(); 73 this.toPersonName = in.readString(); 74 } 75 76 77 protected Message(Parcel in) { 78 readFromParcel(in); 79 } 80 81 public static final Parcelable.Creator<Message> CREATOR = new Parcelable.Creator<Message>() { 82 public Message createFromParcel(Parcel source) { 83 return new Message(source); 84 } 85 86 public Message[] newArray(int size) { 87 return new Message[size]; 88 } 89 }; 90 91 92} 93
###Group
GroupとMessageはParcelableを継承
Java
1public class Group implements Parcelable, Cloneable { 2 3 public Group() { 4 } 5 6 @Override 7 public Group clone() { 8 try { 9 return (Group) super.clone(); 10 } catch (CloneNotSupportedException e) { 11 e.printStackTrace(); 12 } 13 return null; 14 } 15 16 private long groupId; 17 @SerializedName("name") 18 private String groupName; 19 private String description; 20 private String iconUrl; 21 private boolean isOwner; 22 @SerializedName("owner") 23 private String ownerPersonId; 24 private String ownerUserName; 25 private boolean allowDirectMessage; 26 @SerializedName("displayUserName") 27 private boolean allowDisplayUserName; 28 @SerializedName("messageFilter") 29 private boolean allowMessageFilter; 30 @SerializedName("forcePhont") 31 private String fixedPhont; 32 @SerializedName("scope") 33 private int publicStatus; 34 @SerializedName("type") 35 private int joinStatus; 36 private long joinTime; 37 @SerializedName("limit") 38 private int joinLimitNumber; 39 private long updateTime; 40 private int memberCount; 41 private int status; 42 43///省略Getter And Setter 44 45 public void readFromParcel(Parcel in) { 46 this.groupId = in.readLong(); 47 this.groupName = in.readString(); 48 this.description = in.readString(); 49 this.iconUrl = in.readString(); 50 this.isOwner = in.readByte() != 0; 51 this.ownerPersonId = in.readString(); 52 this.ownerUserName = in.readString(); 53 this.allowDirectMessage = in.readByte() != 0; 54 this.allowDisplayUserName = in.readByte() != 0; 55 this.allowMessageFilter = in.readByte() != 0; 56 this.fixedPhont = in.readString(); 57 this.publicStatus = in.readInt(); 58 this.joinStatus = in.readInt(); 59 this.joinTime = in.readLong(); 60 this.joinLimitNumber = in.readInt(); 61 this.updateTime = in.readLong(); 62 this.memberCount = in.readInt(); 63 this.status = in.readInt(); 64 } 65 66 @Override 67 public int describeContents() { 68 return 0; 69 } 70 71 @Override 72 public void writeToParcel(Parcel dest, int flags) { 73 dest.writeLong(this.groupId); 74 dest.writeString(this.groupName); 75 dest.writeString(this.description); 76 dest.writeString(this.iconUrl); 77 dest.writeByte(this.isOwner ? (byte) 1 : (byte) 0); 78 dest.writeString(this.ownerPersonId); 79 dest.writeString(this.ownerUserName); 80 dest.writeByte(this.allowDirectMessage ? (byte) 1 : (byte) 0); 81 dest.writeByte(this.allowDisplayUserName ? (byte) 1 : (byte) 0); 82 dest.writeByte(this.allowMessageFilter ? (byte) 1 : (byte) 0); 83 dest.writeString(this.fixedPhont); 84 dest.writeInt(this.publicStatus); 85 dest.writeInt(this.joinStatus); 86 dest.writeLong(this.joinTime); 87 dest.writeInt(this.joinLimitNumber); 88 dest.writeLong(this.updateTime); 89 dest.writeInt(this.memberCount); 90 dest.writeInt(this.status); 91 } 92 93 protected Group(Parcel in) { 94 this.groupId = in.readLong(); 95 this.groupName = in.readString(); 96 this.description = in.readString(); 97 this.iconUrl = in.readString(); 98 this.isOwner = in.readByte() != 0; 99 this.ownerPersonId = in.readString(); 100 this.ownerUserName = in.readString(); 101 this.allowDirectMessage = in.readByte() != 0; 102 this.allowDisplayUserName = in.readByte() != 0; 103 this.allowMessageFilter = in.readByte() != 0; 104 this.fixedPhont = in.readString(); 105 this.publicStatus = in.readInt(); 106 this.joinStatus = in.readInt(); 107 this.joinTime = in.readLong(); 108 this.joinLimitNumber = in.readInt(); 109 this.updateTime = in.readLong(); 110 this.memberCount = in.readInt(); 111 this.status = in.readInt(); 112 } 113 114 public static final Creator<Group> CREATOR = new Creator<Group>() { 115 @Override 116 public Group createFromParcel(Parcel source) { 117 return new Group(source); 118 } 119 120 @Override 121 public Group[] newArray(int size) { 122 return new Group[size]; 123 } 124 };
###補足情報(言語/FW/ツール等のバージョンなど)
Android Studio 2.1
buildToolsVersion 23.0.3
Android 4.2.2(それ以外の端末でも起こる)
あなたの回答
tips
プレビュー