Rob Spoor wrote:And where do you assign anything to your telnetClient? Because my guess is that you don't, which means the reference remains null.
Rob Spoor wrote:
simone giusti wrote:This is the error:
Attempt to invoke virtual method 'java.lang.String it.rockopera.scsremote.TelnetClient.command(java.lang.String)' on a null object reference
The error is actually pretty clear. Somewhere (not in the code you've shown) you have a reference to a TelnetClient on which you call command. However, that reference is null.
Can you show the piece of code where you call this command method?
Attempt to invoke virtual method 'java.lang.String it.rockopera.scsremote.TelnetClient.command(java.lang.String)' on a null object reference
Tim Moores wrote:Not knowing the IP address would be very unusual. Something like Bonjour might make that possible, but Telnet has really fallen out of favor due to its unsecured nature. Mind telling us a bit about the use case?
simone giusti wrote:Suppose a simple method in MainActivity:
I would like to call it from another class:
This is the result:
Will you help me ???
Thanks.
Ron McLeod wrote:One problem is the you are calling your update method on a new instance of MainActivity, rather than the launched MainActivity instance:
Ron McLeod wrote:Then why not have an instance variable for DBLayer, instantiate it and open the db in onCreate(), use it in UpdateLV(), and close it in onDestroy()?