pls,help me convert to SDK 1.0!

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

pls,help me convert to SDK 1.0!

Postby phannguyen » Thu Oct 02, 2008 3:43 am

now i want to develop on SDK 1.0 but i can't convert these codes to SDK 1.0.
Any body have experience ,please help me.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.OutputStream;
  5.  
  6. import org.apache.commons.httpclient.HostConfiguration;
  7. import org.apache.commons.httpclient.HttpConnection;
  8. import org.apache.commons.httpclient.HttpConnectionManager;
  9. import org.apache.commons.httpclient.HttpState;
  10. import org.apache.commons.httpclient.HttpURL;
  11. import org.apache.commons.httpclient.SimpleHttpConnectionManager;
  12. import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
  13. import org.apache.commons.httpclient.methods.PostMethod;
  14. import org.apache.commons.httpclient.methods.RequestEntity;
  15.  
  16.  
  17.  
  18. /**
  19.  * Connection using apache HttpComponent
  20.  */
  21. public class AndroidServiceConnection implements ServiceConnection {
  22.     private static HttpConnectionManager connectionManager = new SimpleHttpConnectionManager();
  23.     private HttpConnection connection;
  24.     private PostMethod postMethod;
  25.     private java.io.ByteArrayOutputStream bufferStream = null;
  26.    
  27.     /**
  28.      * Constructor taking the url to the endpoint for this soap communication
  29.      * @param url the url to open the connection to.
  30.      */
  31.     public AndroidServiceConnection(String url) throws IOException {
  32.         HttpURL httpURL = new HttpURL(url);
  33.         HostConfiguration host = new HostConfiguration();
  34.         host.setHost(httpURL.getHost(), httpURL.getPort());
  35.         connection = connectionManager.getConnection(host);
  36.         postMethod = new PostMethod(url);
  37.     }
  38.  
  39.     public void connect() throws IOException {
  40.         if (!connection.isOpen()) {
  41.                 connection.open();
  42.         }
  43.     }
  44.  
  45.     public void disconnect() {
  46.         connection.releaseConnection();
  47.     }
  48.  
  49.     public void setRequestProperty(String name, String value) {
  50.         postMethod.setRequestHeader(name, value);
  51.     }
  52.  
  53.    
  54.     public InputStream openInputStream() throws IOException {
  55.         RequestEntity re = new ByteArrayRequestEntity(bufferStream.toByteArray());
  56.         postMethod.setRequestEntity(re);
  57.         postMethod.execute(new HttpState(), connection);
  58.         return postMethod.getResponseBodyAsStream();
  59.     }
  60.  
  61.     public InputStream getErrorStream() {
  62.         return null;
  63.     }
  64.    
  65. }
  66.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

list of classes need changed:
Code: Select all
HttpConnectionManager
SimpleHttpConnectionManager()
HttpConnection
PostMethod
HttpURL
HostConfiguration
RequestEntity
ByteArrayRequestEntity

Please help me convert to SDK 1.0 all these classes or give me a reference.
thanks a lot.
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

Top

Postby ninor » Thu Oct 02, 2008 6:06 am

Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby phannguyen » Thu Oct 02, 2008 10:48 am

thanks for help,
but now i want call webservice on android.
so i can begin from where?
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

Postby ninor » Thu Oct 02, 2008 12:10 pm

There are a couple examples here in AndDev.
Search for Web services, xml, ...
Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby sushil kathade » Tue Apr 07, 2009 7:16 am

phannguyen wrote:thanks for help,
but now i want call webservice on android.
so i can begin from where?



I also want to call web service from emulator.

have you got conversion of above androidServiceConnection class to SDK 1.1

if yes then please send it to me . I need it .


thanks
sushil kathade
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 19, 2009 1:01 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 1 guest