Android parcelable for android objects like mediaplayer -
i have searched today how make parcelable
share objects between activities through intent
. examples found custom objects basic data int
/string
/arraylists
etc. there way make parcelable of mediaplayer
object ? far have this:
public class mpparcelable implements parcelable { private mediaplayer mp; public int describecontents() { return 0; } public void writetoparcel(parcel out, int flags) { out.writevalue(mp); } public static final parcelable.creator<mpparcelable> creator = new parcelable.creator<mpparcelable>() { public mpparcelable createfromparcel(parcel in) { return new mpparcelable(in); } public mpparcelable[] newarray(int size) { return new mpparcelable[size]; } }; private mpparcelable(parcel in) { mp = in.readvalue(); } }
the part don't know todo on setter
if can that: mp = in.readvalue();
don't know how read mediaplayer
object.
is there way make parcelable of mediaplayer object ?
no, because not class. occasionally, can create wrapper around other class , wrapper can parcelable
, not see how work mediaplayer
.
imho, want (sharing mediaplayer
between components) code smell. either each component should have own mediaplayer
, or mediaplayer
should centrally managed (e.g., via service).
Comments
Post a Comment