I have the following code :
@Override
public void onReceive(Context arg0, Intent arg1)
{
String blabla = "blabla";
Handler connectionStatusHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
//Do something with blabla;
}
};
}
Unfortunatly it doesn't work because of the way java handles closures, i can't make blabla final.
So i thought maybe i can do something like this
@Override
public void onReceive(Context arg0, Intent arg1)
{
String blabla = "blabla";
Handler connectionStatusHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
//Do something with localBlabla;
}
public String localBlabla;
};
connectionStatusHandler.localBlabla = blabla;
}
But it doesn't work also because Handler doesn't have a member called localBlabla
.
Technically I can create a not anonymous class that inherits from Handler and add there the members I want, but before i do that i wonder maybe someone has some trick to solve it and pass non-final data to inner class
Thanks