UnknownHostException - Already added permissions!

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

UnknownHostException - Already added permissions!

Postby gabehabe » Sat Feb 07, 2009 7:12 pm

Well this has been driving me mad for a while now. Fairly new to Android development, but not programming. :)

I'm trying to make an IRC client right now, but it's not going too well. I KNOW that my sockets work, because they've been tested in a plain Java Application and it connected, no problems. However, after adding these classes into my Android project, I continually get UnknownHostException errors.

And before you say anything, yes, I've added the permissions. ;)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.INTERNET" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


It's when I instantiate an IRC_Connection object that I get the error. Like I said, it works fine in a Java Application, so I wouldn't have thought there's anything wrong with it. But I'll post it anyway:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import java.net.UnknownHostException;
  2.  
  3. import java.io.IOException;
  4.  
  5. import java.io.PrintStream;
  6.  
  7. import java.net.Socket;
  8.  
  9.  
  10.  
  11. public class IRC_Connection {
  12.  
  13.         private String host;
  14.  
  15.         private int port;
  16.  
  17.         private String nick;
  18.  
  19.         public IRC_Connection(String host, String _nick) throws UnknownHostException, IOException {
  20.  
  21.                 this(host, _nick, 6667);
  22.  
  23.         }
  24.  
  25.          
  26.  
  27.         public IRC_Connection(String host, String _nick, int port) throws UnknownHostException, IOException {
  28.  
  29.                 this.host = host;
  30.  
  31.                 this.port = port;
  32.  
  33.                 this.nick = _nick;
  34.  
  35.                 this.connect();
  36.  
  37.                 this.register();
  38.  
  39.         }
  40.  
  41.          
  42.  
  43.         private PrintStream out;
  44.  
  45.         private void connect() throws UnknownHostException, IOException {
  46.  
  47.                 Socket socket = new Socket( host, port );
  48.  
  49.                 out = new PrintStream(socket.getOutputStream());
  50.  
  51.         }
  52.  
  53.          
  54.  
  55.         private void register() {
  56.  
  57.                 String localhost = "localhost";
  58.  
  59.                 out.println("USER " + this.nick + " " + localhost + " " + host + " " + this.nick);
  60.  
  61.                 out.println("NICK " + this.nick);
  62.  
  63.         }
  64.  
  65.  
  66.  
  67.         public IRC_Channel getChannel(String name) {
  68.  
  69.                 return(new IRC_Channel(name, out));
  70.  
  71.         }
  72.  
  73. }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
Image
User avatar
gabehabe
Freshman
Freshman
 
Posts: 2
Joined: Sat Feb 07, 2009 7:02 pm
Location: Cannock, England

Top

Postby Plastriq » Sun Feb 08, 2009 11:55 pm

The code is working fine for me.
Plastriq
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 05, 2009 3:27 pm
Location: The Netherlands

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests