============ Problem Description ============
The following purple code will cause the program to stop running, please help to solve, tell the reason for younger brother.
public void onconfigurationchanged (Configuration newconfig) {
Mnewconfig=newconfig;
Message message = new Message ();
Message.what = UpdateUi;
uihandler.sendmessage (message);
}
[Color= #CC99FF]
Private Handler Uihandler = new Handler ()
{
public void Handlemessage (Message msg)
{
if (Msg.what==updateui)
Onconfigurationchanged (MNEWCONFIG,MTMP);
}
};
[/color]
public void onconfigurationchanged (Configuration newconfig,int tmp) {
Toast.maketext (Conversationlist.this, "New onconfigurationchanged", Toast.length_long). Show ();
Super.onconfigurationchanged (Newconfig);
}
If Uihandler.sendmessage (message) is not executed, it is called directlyonconfigurationchanged (Configuration newconfig,int tmp)Instead, there's no problem.
============ Solution 1============
You have a dead loop like this, constantly calling onconfigurationchanged, the stack will be full, and the natural program will crash!
============ Solution 2============
You this is a dead loop that will onconfigurationchanged (mnewconfig,mtmp); Move to the message handler function, or onconfigurationchanged (mnewconfig,mtmp); Do not execute the uihandler.sendmessage (message);
============ Solution 3============
Isn't that a dead loop?
Android Handler Help