Hay Guy, I’m using org.apache.commons.net.nntp to connect to a nntp server, however running a simple nntp.connect(host, port) crashes the android.
Anyone got any ideas? Do java packages work with android straight out of the box? or do they need editing?
Thanks
import org.apache.commons.net.nntp.*;
public class newsdroid extends Activity {
NNTP usenet; /** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
usenet.connect("ssl-eu.astraweb.com", 563);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
You need to initialize your variable
usenet, by just usingNTTP usenetits called declaring the variable. It just declares the variable to typeNTTPand it has a reference to nothing, which is commonly defined as beingnull, hence theNullPointerException.You might need to check out
NTTPClientinstead, so add this into your codeThat is initializing the variable
usenetto aNTTPClient.