這是我的locat輸出。android.os.BadParcelableException當通過aidl傳遞對象arraylist時
09-22 11:12:11.985: E/AndroidRuntime(6208): FATAL EXCEPTION: Thread-4521
09-22 11:12:11.985: E/AndroidRuntime(6208): Process: com.acsia.mediaservice:remote, PID: 6208
09-22 11:12:11.985: E/AndroidRuntime(6208): android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.acsia.mediaservice.model.Song
09-22 11:12:11.985: E/AndroidRuntime(6208): at android.os.Parcel.readException(Parcel.java:1467)
09-22 11:12:11.985: E/AndroidRuntime(6208): at android.os.Parcel.readException(Parcel.java:1419)
09-22 11:12:11.985: E/AndroidRuntime(6208): at com.acsia.hmi.IMediaHmi$Stub$Proxy.getPlayListCallBack(IMediaHmi.java:210)
09-22 11:12:11.985: E/AndroidRuntime(6208): at com.acsia.mediaservice.MediaNotificationHandler.broadcastPlaylist(MediaNotificationHandler.java:175)
09-22 11:12:11.985: E/AndroidRuntime(6208): at com.acsia.mediaservice.MediaNotificationHandler.broadcastStartUp(MediaNotificationHandler.java:161)
09-22 11:12:11.985: E/AndroidRuntime(6208): at com.acsia.mediaservice.MediaService$3.run(MediaService.java:253)
09-22 11:12:11.985: E/AndroidRuntime(6208): at java.lang.Thread.run(Thread.java:841)
什麼,我試圖做的是我有一個模型類callsed宋它實現Parcelable如下:
public class Song implements Parcelable {
String albumID;
String songTitle;
String displayName;
String duration;
String artist;
String songPath;
String albumPath;
public String getAlbumID() {
return albumID;
}
public void setAlbumID(String albumID) {
this.albumID = albumID;
}
public String getSongTitle() {
return songTitle;
}
public void setSongTitle(String songTitle) {
this.songTitle = songTitle;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getArtist() {
return artist;
}
public void setArtist(String artist) {
this.artist = artist;
}
public String getSongPath() {
return songPath;
}
public void setSongPath(String songPath) {
this.songPath = songPath;
}
public String getAlbumPath() {
return albumPath;
}
public void setAlbumPath(String albumPath) {
this.albumPath = albumPath;
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
public Song() {
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(albumID);
dest.writeString(songTitle);
dest.writeString(displayName);
dest.writeString(duration);
dest.writeString(artist);
dest.writeString(songPath);
dest.writeString(albumPath);
}
public static final Parcelable.Creator<Song> CREATOR = new Parcelable.Creator<Song>() {
public Song createFromParcel(Parcel in) {
return new Song(in);
}
public Song[] newArray(int size) {
return new Song[size];
}
};
private Song(Parcel in) {
albumID = in.readString();
songTitle = in.readString();
displayName = in.readString();
duration = in.readString();
artist = in.readString();
songPath = in.readString();
albumPath = in.readString();
}
@Override
public String toString() {
return "Song [albumID=" + albumID + ", songTitle=" + songTitle + ", displayName=" + displayName + ", duration="
+ duration + ", artist=" + artist + ", songPath=" + songPath + ", albumPath=" + albumPath + "]";
}
}
我AIDL
我有方法
void getPlayListCallBack(in Intent data);
和我打電話這作爲
if (mediaHmi != null && serviceConnection != null) {
System.out.println("broadcastStartUp intent: "+from);
Intent intent = new Intent();
intent.putParcelableArrayListExtra("data", (ArrayList<? extends Parcelable>) MediaDataManager.getInstance().getMediasList());
mediaHmi.getPlayListCallBack(intent);//MediaDataManager.getInstance().getPlayList());
}
我正的錯誤在這條線intent.putParcelableArrayListExtra("data", (ArrayList<? extends Parcelable>) MediaDataManager.getInstance().getMediasList());
你有沒有試過'MediaDataManager.getInstance()。getMediasList()'? –
我只需要通過aidl發送一個宋類對象的數組列表。也歡迎使用意圖以外的其他方法... –
是的,我試過 –