Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11001
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java listener |
| Date | 2011-12-26 08:12 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <jda6d8$ij0$1@dont-email.me> (permalink) |
| References | <9a7gf750th7582hnjvfv9n0iko35omb57o@4ax.com> |
On 12/25/2011 11:12 PM, Jim Lee wrote:
> How do I implement the ConnectionListener interface and how do I pass
> it into "httpPost" method to get invoked when "listener event" get
> response from the httpPost?
1. Sub-class ConnectionListener to make a concrete class
2. Create an object of that concrete class to pass to httpPost.
As Stefan pointed out, interfaces are not passed as arguments, objects
are, so you need to get an object to pass as a parameter.
public class MyListener implements ConnectionListener {
public void onConnection(int status, InputStream is,
HttpMessage message) {
System.out.println( "onConnection invoked" );
}
public void onConnectionException(Exception e){
System.out.println( "onConnectionException invoked" ) {
}
}
> =====================================
>
> public void httpPost(String url, List<Header> headers, HttpEntity
> body, ConnectionListener listener) {
MyListener listener = new MyListener();
> HttpPostTask task = new HttpPostTask(url, headers, body,
> listener);
> mExecutor.submit(task);
> }
>
> =====================================
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java listener Jim Lee <jimlee2907@yahoo.com> - 2011-12-25 23:12 -0800
Re: Java listener "John B. Matthews" <nospam@nospam.invalid> - 2011-12-26 10:58 -0500
Re: Java listener Arne Vajhøj <arne@vajhoej.dk> - 2011-12-27 17:59 -0500
Re: Java listener markspace <-@.> - 2011-12-26 08:12 -0800
Re: Java listener Roedy Green <see_website@mindprod.com.invalid> - 2011-12-27 12:33 -0800
csiph-web