there are 2 activity A and Screen in A Activity , i made handler and want to pass it to screen activity
Handler error_handler = new Handler() {
public void handleMessage(Message msg) {
}};
Intent loginButton_intent = new Intent(A.this, Screen.class);
loginButton_intent.putExtra("URL", URL);
loginButton_intent.putExtra("IP_Addres", dvr_login_data.IP_Addres);
loginButton_intent.("HAND", error_handler); <- but 开发者_运维知识库this code is error
how can i pass handler ? plz warm-answer
still looking for an answer? I had the same problem and found this question through google, so others might show up as well.
Anyways, I found my solution to the problem of using a handler between a service and an activity in the Android documentation. Just look at the Remote Messenger Service Sample right here: Remote Messenger Service Sample
Basically they are using a messenger as client interface for a local handler in the service.
Regards, Michael
Well, to keep it short, you can't...Handler
implements neithor Serializable
nor Parcelable
so it cannot be put as an extra
...The Object Transported using Intents must follow eithor of those protocols.
Speculation
I suppose, there's an alternative that would involve creating a Service
to act as a middle man. But that'll require some testing.
You can't pass Handler directly through an Activity's Extras, but you can pass in Messenger(handler).
精彩评论