Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Parcelable CREATOR field?

My ResultReceiver subclass:

private class MyReceiver extends ResultReceiver {
    public MyReceiver() {
        super(null);
    }
    @Override 
    protected void onReceiveResult(int resultCode, Bundle data) {
        // yada yada
    }
}

Android Studio throws a wobbly about "Missing Parcelable CREATOR field". But you can see that my subclass doesn't any introduce any new members that would need to be packed into the Parcel. Is Android Studio being overly paranoid, or did I really need to implement a CREATOR field?

For now, I'm adding this:

@SuppressLint("ParcelCreator")

and the problem goes away, but I want to make sure I'm not missing something.

like image 855
Edward Falk Avatar asked Mar 23 '16 00:03

Edward Falk


1 Answers

Parcelable creators are typed to the specific class that's being serialized, so to be safe and complete, you should have a properly creator for every class that could be parceled.

like image 78
Doug Stevenson Avatar answered Sep 21 '22 11:09

Doug Stevenson