ClassNotFoundException when using custom Parcelable

前端 未结 3 1699
孤街浪徒
孤街浪徒 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:31

    There is also a bug in Android that can explain this issue in case you try to pass an intent another intent : https://code.google.com/p/android/issues/detail?id=179480&thanks=179480&ts=1436464704

    0 讨论(0)
  • 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);
    
    0 讨论(0)
  • 2020-12-30 07:45

    Put com.company.project.MyParcelable in the actual application, instead of doing whatever games you are playing with classloaders. Then, it should be available from both the sender and recipient of the Intent.

    0 讨论(0)
提交回复
热议问题