android - Bundle putIBinder getIBinder deprecated -
it seems bundle has deprecated putibinder , getibinder thought useful passing binders (through bundles) on service. since these deprecated, there alternative this?
i need pass ibinder object on service, , thought bundle approach easiest (best) solution this.
thanks, j
posting may deals binders. use approach, still works bundle
// write bundle.putparcelable(key, new parcelablebinder(binder)); // read parcelablebinder value = bundle.getparcelable(key); ibinder binder = binder == null ? null : value.getbinder(); // or possible npe ibinder binder = bundle.<parcelablebinder>getparcelable(key).getbinder() public static class parcelablebinder implements parcelable { ibinder mbinder; public parcelablebinder(ibinder binder) { mbinder = binder; } private parcelablebinder(parcel in) { mbinder = in.readstrongbinder(); } public ibinder getbinder() { return mbinder; } @override public int describecontents() { return 0; } @override public void writetoparcel(parcel dest, int flags) { dest.writestrongbinder(mbinder); } public static final creator<parcelablebinder> creator = new creator<parcelablebinder>() { @override public parcelablebinder createfromparcel(parcel in) { return new parcelablebinder(in); } @override public parcelablebinder[] newarray(int size) { return new parcelablebinder[size]; } }; }
Comments
Post a Comment