Thank you for your reply.
I did whatever you suggested and now all the errors are gone.
However the application is not working as intended.
I use a button to trigger this class which is an activity.
some of the relevant code of that class is as below...
Using java Syntax Highlighting
.
.
.
.
class MyHandler extends Handler {
TerminalView tv;
TextView txt;
MyHandler(TerminalView termView, TextView txt) {
super();
tv = termView;
this.txt = txt;
}
public void handleMessage(android.os.Message msg) {
Serializable serialized = msg.getData().getSerializable("hashmap");
HashMap<String, String> hm = (HashMap<String, String>) serialized;
String msgText = hm.get("message");
if(msg.what == 0)
{
tv.cp.AddBuffer(msgText.toCharArray());
tv.invalidate(0,0,Integer.MAX_VALUE,Integer.MAX_VALUE);
txt.setVisibility(View.INVISIBLE);
}
else if(msg.what == 1)
{
txt.setText(msgText);
txt.setTextColor(0xFFFF0000);
txt.setVisibility(View.VISIBLE);
}
else if(msg.what == 2)
{
txt.setText(msgText);
txt.setTextColor(0xFF00FF00);
txt.setVisibility(View.VISIBLE);
}
}
}
class TerminalSocket implements Runnable {
public Thread tr;
private MyHandler hnd;
protected Socket sk = null;
private InputStream iStream = null;
public OutputStream oStream = null;
public byte X = 1;
public byte Y = 1;
protected String Server = "";
protected int Port = 0;
public TerminalSocket(MyHandler h) {
hnd = h;
tr = new Thread(this);
}
public void SocketStart() {
tr.start();
}
private Message StringToMessage(String s) {
Message msg = new Message();
msg.what = 0;
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("message", s);
Bundle bundle = new Bundle();
bundle.putSerializable("hashmap", hm);
msg.setData(bundle);
return msg;
}
private Message ErrorToMessage(String s) {
Message msg = new Message();
msg.what = 1;
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("message", s);
Bundle bundle = new Bundle();
bundle.putSerializable("hashmap", hm);
msg.setData(bundle);
return msg;
}
private Message InfoToMessage(String s) {
Message msg = new Message();
msg.what = 2;
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("message", s);
Bundle bundle = new Bundle();
bundle.putSerializable("hashmap", hm);
msg.setData(bundle);
return msg;
}
public void run() {
InetAddress ia = null;
hnd.sendMessage(InfoToMessage("Resolve server name " + Server));
try {
ia = InetAddress.getByName(Server);
} catch (UnknownHostException ex) {
hnd.sendMessage(ErrorToMessage("Unknown host " + Server));
return;
}
hnd.sendMessage(InfoToMessage("Connecting to " + Server + ":" + Port));
try {
sk = new java.net.Socket(ia, Port);
} catch (IOException ex) {
hnd.sendMessage(ErrorToMessage("Socket time out for " + Server + ":" + Port));
return;
}
try {
iStream = sk.getInputStream();
oStream = sk.getOutputStream();
} catch (IOException ex) {
hnd.sendMessage(ErrorToMessage("Protocol error for " + Server + ":" + Port));
return;
}
.
.
.
.
Parsed in 0.049 seconds, using
GeSHi 1.0.8.4
when i was using the older sdk, after triggering the class
i was getting the msg : "connecting to <servername and port>"
which would later connect to a server.
but now after changing the code
I directly get the message caused by IOException : "Socket timeout for <servername>"
and does not proceed at all.
I'm sure this is happening because of the modifications made to the code. But I'm unable to find a relevant substitute for functions corresponding to the newer sdk in order to exactly match what i had done in the previous sdk.
any suggestions on this would be appreciated. thanx a lot.