ClassNotFoundException when using custom Parcelable

前端 未结 3 1693
孤街浪徒
孤街浪徒 2020-12-30 07:16

I use a custom Parcelable to carry some data to a BroadcastReceiver. Here is what i do:

I register my intent and set the extra Parcelable on it along with an extra c

3条回答
  •  有刺的猬
    2020-12-30 07:41

    Seems that you face with the issue described here: https://code.google.com/p/android/issues/detail?id=6822

    There is a workaround described in one of comments under that link: put your custom Parcelable into an additional Bundle. Due to the fact that Bundle internals are not touched until it's needed, such an Intent can be delivered to your app, since nobody will try to unmarshal your class outside your app.

      Bundle hackBundle = new Bundle();
      hackBundle.put("key", myParcelable);
      intent.putExtra("bundleKey", hackBundle);
    

提交回复
热议问题