I was experimenting with extending the Intent class but don't seem to make
it work properly. I am wondering if extending is even possible. Here is the
snippets.
Code for custom intent:
public class MyIntent extends Intent {
private MyClass myClass;
public MyIntent(String name, MyClass myClass) {
super(name);
this.myClass = myClass;
}
public MyClass getMyClass() {
return myClass;
}
}
Code for Intent broadcast:
MyClass myClass = new MyClass();
Intent intent = new MyIntent("my_intent",myClass);
sendBroadcast(intent);
Code for BroadcastReceiver.onReceive(Intent intent):
MyClass myClass = null;
if(intent instanceof MyIntent) {
// do something
}
else {
// probelm...
}
When this application runs, I don't see the MyIntent received properly. In
fact, 'intent instanceof MyIntent' seems to return false.
What is wrong?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---