Reputation: 307
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case Constants.MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj;
String Message = new String(readBuf, 0, msg.arg1);
}
break;
public void condition(){
//get Message
}
Hi How do I get/return the message in the switch case handler message to pass into the condition method/function?
Upvotes: 1
Views: 177
Reputation: 56
Did you try implementing String Message="" in the top of your class and using it in the function ? it will be global .
Upvotes: 1
Reputation: 8548
You can extend Handler
create a class and save a field in it,then provide getter and setter method to visit data.
public static class MyHandler extends Handler{
//add your field and getter/setter method
public void handleMessage(Message msg) {
//visit your field
}
}
Upvotes: 1