Special URI order by android?

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

Special URI order by android?

Postby Jimmy Malibu » Tue Aug 05, 2008 3:23 pm

Hallo!
Has got android a special URI order to list a URI?
When my code is reading in a javaprogram I get a String back.
When my code is reading in android then I get nothing no failure, too.
I have debuggt my code and the problem was the order
"URL url = new URL( "http://localhost:8046/IListServices" );
is = url.openStream();
"
Know anyone my problem?

Hier my code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import java.io.IOException;
  3.  
  4. import java.io.InputStream;
  5.  
  6. import java.net.HttpURLConnection;
  7.  
  8. import java.net.URL;
  9.  
  10. import java.util.Scanner;
  11.  
  12. class ReadAllFromUrl
  13.  
  14. {
  15.  
  16.         String name;
  17.  
  18.         String kurzN;
  19.  
  20.         String version;
  21.  
  22.        
  23.  
  24.     public void url(){
  25.  
  26.          InputStream is = null;
  27.  
  28.    
  29.  
  30.     try
  31.  
  32.     {
  33.  
  34.       URL url = new URL( "http://localhost:8046/IListServices" );
  35.  
  36.       is = url.openStream();
  37.  
  38.      
  39.  
  40.       Scanner scanner = new Scanner(is);
  41.  
  42.      
  43.  
  44.       String[] splittArray;
  45.  
  46.      
  47.  
  48.            splittArray = scanner.next().split(" ");
  49.  
  50.            
  51.  
  52.                 name = splittArray[0]; //await the first String from splittArray
  53.  
  54.                
  55.  
  56.     }
  57.  
  58.    
  59.  
  60.     catch ( Exception e ) {
  61.  
  62.       e.printStackTrace();
  63.  
  64.     }
  65.  
  66.     finally {
  67.  
  68.       if ( is != null )
  69.  
  70.         try { is.close(); } catch ( IOException e ) { e.printStackTrace(); }
  71.  
  72.     }
  73.  
  74.   }
  75.  
  76. }
  77.  
  78.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Jimmy Malibu
Freshman
Freshman
 
Posts: 5
Joined: Fri May 23, 2008 10:30 am

Top

Postby cgreen » Wed Aug 06, 2008 9:12 am

This is because localhost points to your android emulator, and not your webservice, which is probably located on your computer. Think of the emulator as an independent device.

You'll have to insert the numerical IP-Address of the computer, which hosts the webservice. ( e.g.: 192.168.2.123 )
User avatar
cgreen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Wed Jul 16, 2008 10:16 am

Re:

Postby Jimmy Malibu » Thu Aug 07, 2008 12:07 pm

Thanks for your help, it was the right solution for my problem.
Jimmy Malibu
Freshman
Freshman
 
Posts: 5
Joined: Fri May 23, 2008 10:30 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 7 guests