I set a button in an Android program to connect to .net PC.
Here is my code:
public void onClick(View v) {
// TODO Auto-generated method stub
if(v==btn_con){
try{
s=new Socket("xxx.xxx.xxx.xxx", xxxx);
BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream()));
String str=in.readLine();
Toast t=Toast.makeText(this, str, Toast.LENGTH_LONG);
t.show();
_isconnected=true;
}catch(Exception e){
Toast t=Toast.makeText(this, "链接发生错误"+e.getMessage(), Toast.LENGTH_LONG);
t.show();
System.out.println("连接发生错误:"+e.getMessage());
}
}
When I run the program it throws a Permission denied exception. I have run a .net service program; this is a client Android program. If I run a Java client it has no such problem. When I run the Android program in my phone, I don't know how to solve the problem.