@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
final String action = intent.getAction();
if (ACTION_UPDATE_SERVER.equals(action)) {
final Server server = (Server)intent.getSerializableExtra(SERVER);
handleActionUpdateServer(server);
[...]
}
}
}
server is a model class I made where I override toString().
In the line
final Server server = (Server)intent.getSerializableExtra(SERVER);
I get this error
[package].[app] Java.lang.NullPointerException exception: cannot evaluate server.toString()
it seems like it is unable to retrieve the serialized extra because of this error.
but if I remove my implementation of toString() then there's no error. Problem is I need to override toString for a listView to use when displaying objects of the server class in the list. (there's no problems with the toString() method when being run to populate the list.
my implementation of toString looks like this:
@Override
public String toString() {
StringBuilder strb = new StringBuilder(serverTitle);
strb.append(" | Monitored: ");
strb.append(isMonitored);
strb.append(" | Online: ");
strb.append(isOnline);
return strb.toString();
}
why is it unable to evaluate server.toString when I override it myself and why is it even trying to?
don't mark this as duplicate of nullPointerException questions as this doesn't help me at all. The app doesn't crash after this error, it keeps running and to me the error seems to have to do with my implementation of toString()