Android Intent Subclass

I use intentions as a messaging engine between the various parts of my Android application.

My question is: can I subclass Intent to create my own classes on top of it, or will it be a standard Intent class when I get it in the Broadcast receiver?

Of course, I'm talking about intra-production communication. But the transverse thread.

+4
source share
1 answer

I have never done this myself, but I think it is possible. LabeledIntent documentation and source - I think this is similar to what you are describing. When working with your custom Intent in your receiver, you need to specify the Intent parameter in onReceive() in your own subclass.

If you add any fields to your subclass, you will need to correctly implement the Parcelable methods - make sure you override writeToParcel() , you have a constructor that accepts this particular Parcel parameter, and a public static final Parcelable.Creator .

+5
source

All Articles