Re: [android-developers] Re: Best HTTP Request Method

2010-01-02 Thread Frank Weiss
Here's roughly how I do it, for a GET request:

class RSS exends DefaultHandler {
StringBuffer sb;
... other variables for collecting the data
public void parse(URL url) throws Exception{
SAXParserFactory spf = SAXParserFactory.*newInstance*();
SAXParser parser = spf.newSAXParser();
parser.parse(url.openConnection().getInputStream(), this);
}
@Override
*public* *void* startElement(String namespaceUri, String localName,
String qName, Attributes attrs) {
   sb = new StringBuilder();
..
}
*...@override*
*public void characters(char[] ch, int offset, int count) {*
*sb.append(ch, offset, count);*
*}*
*@Override*
*public* *void* endElement(String namespaceUri, String localName, String
qName) {
if (localName.equals("someelement") {
 somevariable = sb.toString();
   }
   ...
}
}

This is only a sketch, but it shows how easy the connection is made via
java.net and the skeleton of how the callbacks collect the data.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Best HTTP Request Method

2010-01-02 Thread SizzlingSkizzorsProgrammer
Thanks, btw...great help!

On Jan 2, 5:38 pm, Frank Weiss  wrote:
> You haven't said how big the response content is, which certainly can be a
> factor. I looked at the EntityUtils.toString() source code in HttpCore 4.0.1
> and it is basically using an InputStreamReader to decode the entity into a
> String, using a 1024 character buffer. Are you sure you want the entity as a
> string? Can you process it as a stream? AFAIK HTTPClient does allows for
> stream processing of the response. This is usually much more efficient than
> copying the whole thing into a memory buffer.
>
> On Sat, Jan 2, 2010 at 10:24 AM, SizzlingSkizzorsProgrammer <
>
>
>
> cbo...@gmail.com> wrote:
> > Thanks!
>
> > After doing a TraceView, I found that most of the processing time is
> > spent in the EntityUtils.toString(entity); portion...any ideas how to
> > speed it up/circumvent this step?
>
> > On Jan 2, 12:47 am, Brion Emde  wrote:
> > > I think that it is automatic. Just be sure to keep your HttpClient
> > > object around for as long as you're going to be using it. For example:
> > > create the HttpClient in your onCreate() and close it in onDestroy()
> > > for your activity.
>
> > > On Jan 1, 10:45 pm, SizzlingSkizzorsProgrammer 
> > > wrote:
>
> > > > Thanks a lot!  Just wondering:  how do you set the keep-alive
> > > > setting?  I just can't seem to get it!
>
> > > > Thanks for all your help!
>
> > > > On Jan 1, 5:08 pm, Frank Weiss  wrote:
>
> > > > > I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> > > > > java.net.URL.openConnection().getInputStream() and then parsing it
> > with
> > > > > SAXParser. It looks like you're doing a POST to send form data(?) so
> > you may
> > > > > have to stick with HTTPClient.
>
> > > > > If you're doing frequent requests, you can probably take advantage of
> > > > > HTTPClient's "keep-alive" connection management.
>
> > > > > If you're looking for optimizations, I strongly suggest you create a
> > test
> > > > > app which performs the samerequestyou're having performance problems
> > with.
> > > > > Collect more data, such as the size of therequestand response. Try
> > the
> > > > > samerequestfrom a different platform (like your laptop or desktop).
> > > > > Compare the network paths between the desktop and Android to the
> > server.
>
> > > > > I know you'd like to just get an answer "do this/try this". I hope
> > that by
> > > > > looking into the problem in more detail you''ll find a solution.
>
> > > > > On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com
>
> > > > > > wrote:
> > > > > > About 5 seconds, which isn't unbearable, but considering my app
> > needs
> > > > > > frequent requests some kind of optimization must be possible.
>
> > > > > > Look at the android market...it seems to load everything pretty
> > fast
> > > > > > (much faster than my app at least!)
>
> > > > > > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > > > > > Considering that the execute method's latency includes network
> > and server
> > > > > > > times, on what basis do you think it's taking too long? What
> > latency are
> > > > > > you
> > > > > > > observing, less than one second, more than one minute?
>
> > > > > > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > > > > > cbo...@gmail.com
>
> > > > > > > > wrote:
> > > > > > > > Yes, I've tried logging and theHTTPexecute definitely takes the
> > > > > > > > largest chunk of time, but how can I speed it up?  Is there
> > another
> > > > > > > > protocol/method?
>
> > > > > > > > On Dec 31 2009, 6:07 pm, jotobjects 
> > wrote:
> > > > > > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com>
> > > > > > > > > wrote:
>
> > > > > > > > > > It works fine, but it's quite slow...any way to make it
> > faster?
>
> > > > > > > > > A guess would be that theHTTPnetwork speed is 100's of times
> > slower
> > > > > > > > > than all the rest of the code. You might log the time before
> > and
> > > > > > after
> > > > > > > > > the execute method if you haven't already done that.
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > Groups "Android Developers" group.
> > > > > > > > To post to this group, send email to
> > > > > > android-developers@googlegroups.com
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > android-developers+unsubscr...@googlegroups.com > > > > > > >  cr...@googlegroups.com> > cr...@googlegroups.com> > > > > > cr...@googlegroups.com>
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > android-developers@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > andr

[android-developers] Re: Best HTTP Request Method

2010-01-02 Thread SizzlingSkizzorsProgrammer
The response content varies, but it frequently is large(ish), normally
up to 64 kb...I could process it as a stream, but what is the best way
to parse xml via stream?

On Jan 2, 5:38 pm, Frank Weiss  wrote:
> You haven't said how big the response content is, which certainly can be a
> factor. I looked at the EntityUtils.toString() source code in HttpCore 4.0.1
> and it is basically using an InputStreamReader to decode the entity into a
> String, using a 1024 character buffer. Are you sure you want the entity as a
> string? Can you process it as a stream? AFAIK HTTPClient does allows for
> stream processing of the response. This is usually much more efficient than
> copying the whole thing into a memory buffer.
>
> On Sat, Jan 2, 2010 at 10:24 AM, SizzlingSkizzorsProgrammer <
>
>
>
> cbo...@gmail.com> wrote:
> > Thanks!
>
> > After doing a TraceView, I found that most of the processing time is
> > spent in the EntityUtils.toString(entity); portion...any ideas how to
> > speed it up/circumvent this step?
>
> > On Jan 2, 12:47 am, Brion Emde  wrote:
> > > I think that it is automatic. Just be sure to keep your HttpClient
> > > object around for as long as you're going to be using it. For example:
> > > create the HttpClient in your onCreate() and close it in onDestroy()
> > > for your activity.
>
> > > On Jan 1, 10:45 pm, SizzlingSkizzorsProgrammer 
> > > wrote:
>
> > > > Thanks a lot!  Just wondering:  how do you set the keep-alive
> > > > setting?  I just can't seem to get it!
>
> > > > Thanks for all your help!
>
> > > > On Jan 1, 5:08 pm, Frank Weiss  wrote:
>
> > > > > I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> > > > > java.net.URL.openConnection().getInputStream() and then parsing it
> > with
> > > > > SAXParser. It looks like you're doing a POST to send form data(?) so
> > you may
> > > > > have to stick with HTTPClient.
>
> > > > > If you're doing frequent requests, you can probably take advantage of
> > > > > HTTPClient's "keep-alive" connection management.
>
> > > > > If you're looking for optimizations, I strongly suggest you create a
> > test
> > > > > app which performs the samerequestyou're having performance problems
> > with.
> > > > > Collect more data, such as the size of therequestand response. Try
> > the
> > > > > samerequestfrom a different platform (like your laptop or desktop).
> > > > > Compare the network paths between the desktop and Android to the
> > server.
>
> > > > > I know you'd like to just get an answer "do this/try this". I hope
> > that by
> > > > > looking into the problem in more detail you''ll find a solution.
>
> > > > > On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com
>
> > > > > > wrote:
> > > > > > About 5 seconds, which isn't unbearable, but considering my app
> > needs
> > > > > > frequent requests some kind of optimization must be possible.
>
> > > > > > Look at the android market...it seems to load everything pretty
> > fast
> > > > > > (much faster than my app at least!)
>
> > > > > > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > > > > > Considering that the execute method's latency includes network
> > and server
> > > > > > > times, on what basis do you think it's taking too long? What
> > latency are
> > > > > > you
> > > > > > > observing, less than one second, more than one minute?
>
> > > > > > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > > > > > cbo...@gmail.com
>
> > > > > > > > wrote:
> > > > > > > > Yes, I've tried logging and theHTTPexecute definitely takes the
> > > > > > > > largest chunk of time, but how can I speed it up?  Is there
> > another
> > > > > > > > protocol/method?
>
> > > > > > > > On Dec 31 2009, 6:07 pm, jotobjects 
> > wrote:
> > > > > > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com>
> > > > > > > > > wrote:
>
> > > > > > > > > > It works fine, but it's quite slow...any way to make it
> > faster?
>
> > > > > > > > > A guess would be that theHTTPnetwork speed is 100's of times
> > slower
> > > > > > > > > than all the rest of the code. You might log the time before
> > and
> > > > > > after
> > > > > > > > > the execute method if you haven't already done that.
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > Groups "Android Developers" group.
> > > > > > > > To post to this group, send email to
> > > > > > android-developers@googlegroups.com
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > android-developers+unsubscr...@googlegroups.com > > > > > > >  cr...@googlegroups.com> > cr...@googlegroups.com> > > > > > cr...@googlegroups.com>
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to

Re: [android-developers] Re: Best HTTP Request Method

2010-01-02 Thread Frank Weiss
You haven't said how big the response content is, which certainly can be a
factor. I looked at the EntityUtils.toString() source code in HttpCore 4.0.1
and it is basically using an InputStreamReader to decode the entity into a
String, using a 1024 character buffer. Are you sure you want the entity as a
string? Can you process it as a stream? AFAIK HTTPClient does allows for
stream processing of the response. This is usually much more efficient than
copying the whole thing into a memory buffer.

On Sat, Jan 2, 2010 at 10:24 AM, SizzlingSkizzorsProgrammer <
cbo...@gmail.com> wrote:

> Thanks!
>
> After doing a TraceView, I found that most of the processing time is
> spent in the EntityUtils.toString(entity); portion...any ideas how to
> speed it up/circumvent this step?
>
> On Jan 2, 12:47 am, Brion Emde  wrote:
> > I think that it is automatic. Just be sure to keep your HttpClient
> > object around for as long as you're going to be using it. For example:
> > create the HttpClient in your onCreate() and close it in onDestroy()
> > for your activity.
> >
> > On Jan 1, 10:45 pm, SizzlingSkizzorsProgrammer 
> > wrote:
> >
> >
> >
> > > Thanks a lot!  Just wondering:  how do you set the keep-alive
> > > setting?  I just can't seem to get it!
> >
> > > Thanks for all your help!
> >
> > > On Jan 1, 5:08 pm, Frank Weiss  wrote:
> >
> > > > I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> > > > java.net.URL.openConnection().getInputStream() and then parsing it
> with
> > > > SAXParser. It looks like you're doing a POST to send form data(?) so
> you may
> > > > have to stick with HTTPClient.
> >
> > > > If you're doing frequent requests, you can probably take advantage of
> > > > HTTPClient's "keep-alive" connection management.
> >
> > > > If you're looking for optimizations, I strongly suggest you create a
> test
> > > > app which performs the samerequestyou're having performance problems
> with.
> > > > Collect more data, such as the size of therequestand response. Try
> the
> > > > samerequestfrom a different platform (like your laptop or desktop).
> > > > Compare the network paths between the desktop and Android to the
> server.
> >
> > > > I know you'd like to just get an answer "do this/try this". I hope
> that by
> > > > looking into the problem in more detail you''ll find a solution.
> >
> > > > On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer <
> cbo...@gmail.com
> >
> > > > > wrote:
> > > > > About 5 seconds, which isn't unbearable, but considering my app
> needs
> > > > > frequent requests some kind of optimization must be possible.
> >
> > > > > Look at the android market...it seems to load everything pretty
> fast
> > > > > (much faster than my app at least!)
> >
> > > > > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > > > > Considering that the execute method's latency includes network
> and server
> > > > > > times, on what basis do you think it's taking too long? What
> latency are
> > > > > you
> > > > > > observing, less than one second, more than one minute?
> >
> > > > > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > > > > cbo...@gmail.com
> >
> > > > > > > wrote:
> > > > > > > Yes, I've tried logging and theHTTPexecute definitely takes the
> > > > > > > largest chunk of time, but how can I speed it up?  Is there
> another
> > > > > > > protocol/method?
> >
> > > > > > > On Dec 31 2009, 6:07 pm, jotobjects 
> wrote:
> > > > > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer <
> cbo...@gmail.com>
> > > > > > > > wrote:
> >
> > > > > > > > > It works fine, but it's quite slow...any way to make it
> faster?
> >
> > > > > > > > A guess would be that theHTTPnetwork speed is 100's of times
> slower
> > > > > > > > than all the rest of the code. You might log the time before
> and
> > > > > after
> > > > > > > > the execute method if you haven't already done that.
> >
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> Google
> > > > > > > Groups "Android Developers" group.
> > > > > > > To post to this group, send email to
> > > > > android-developers@googlegroups.com
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > android-developers+unsubscr...@googlegroups.com cr...@googlegroups.com> > > > > cr...@googlegroups.com>
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/android-developers?hl=en
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to
> android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Grou

[android-developers] Re: Best HTTP Request Method

2010-01-02 Thread SizzlingSkizzorsProgrammer
Thanks!

After doing a TraceView, I found that most of the processing time is
spent in the EntityUtils.toString(entity); portion...any ideas how to
speed it up/circumvent this step?

On Jan 2, 12:47 am, Brion Emde  wrote:
> I think that it is automatic. Just be sure to keep your HttpClient
> object around for as long as you're going to be using it. For example:
> create the HttpClient in your onCreate() and close it in onDestroy()
> for your activity.
>
> On Jan 1, 10:45 pm, SizzlingSkizzorsProgrammer 
> wrote:
>
>
>
> > Thanks a lot!  Just wondering:  how do you set the keep-alive
> > setting?  I just can't seem to get it!
>
> > Thanks for all your help!
>
> > On Jan 1, 5:08 pm, Frank Weiss  wrote:
>
> > > I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> > > java.net.URL.openConnection().getInputStream() and then parsing it with
> > > SAXParser. It looks like you're doing a POST to send form data(?) so you 
> > > may
> > > have to stick with HTTPClient.
>
> > > If you're doing frequent requests, you can probably take advantage of
> > > HTTPClient's "keep-alive" connection management.
>
> > > If you're looking for optimizations, I strongly suggest you create a test
> > > app which performs the samerequestyou're having performance problems with.
> > > Collect more data, such as the size of therequestand response. Try the
> > > samerequestfrom a different platform (like your laptop or desktop).
> > > Compare the network paths between the desktop and Android to the server.
>
> > > I know you'd like to just get an answer "do this/try this". I hope that by
> > > looking into the problem in more detail you''ll find a solution.
>
> > > On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer 
> > > 
> > > > wrote:
> > > > About 5 seconds, which isn't unbearable, but considering my app needs
> > > > frequent requests some kind of optimization must be possible.
>
> > > > Look at the android market...it seems to load everything pretty fast
> > > > (much faster than my app at least!)
>
> > > > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > > > Considering that the execute method's latency includes network and 
> > > > > server
> > > > > times, on what basis do you think it's taking too long? What latency 
> > > > > are
> > > > you
> > > > > observing, less than one second, more than one minute?
>
> > > > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > > > cbo...@gmail.com
>
> > > > > > wrote:
> > > > > > Yes, I've tried logging and theHTTPexecute definitely takes the
> > > > > > largest chunk of time, but how can I speed it up?  Is there another
> > > > > > protocol/method?
>
> > > > > > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > > > > > wrote:
>
> > > > > > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > > > > > A guess would be that theHTTPnetwork speed is 100's of times 
> > > > > > > slower
> > > > > > > than all the rest of the code. You might log the time before and
> > > > after
> > > > > > > the execute method if you haven't already done that.
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > > > android-developers@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > android-developers+unsubscr...@googlegroups.com > > > > >  cr...@googlegroups.com> > > > cr...@googlegroups.com>
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com > > >  cr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread Brion Emde
I think that it is automatic. Just be sure to keep your HttpClient
object around for as long as you're going to be using it. For example:
create the HttpClient in your onCreate() and close it in onDestroy()
for your activity.

On Jan 1, 10:45 pm, SizzlingSkizzorsProgrammer 
wrote:
> Thanks a lot!  Just wondering:  how do you set the keep-alive
> setting?  I just can't seem to get it!
>
> Thanks for all your help!
>
> On Jan 1, 5:08 pm, Frank Weiss  wrote:
>
>
>
> > I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> > java.net.URL.openConnection().getInputStream() and then parsing it with
> > SAXParser. It looks like you're doing a POST to send form data(?) so you may
> > have to stick with HTTPClient.
>
> > If you're doing frequent requests, you can probably take advantage of
> > HTTPClient's "keep-alive" connection management.
>
> > If you're looking for optimizations, I strongly suggest you create a test
> > app which performs the same request you're having performance problems with.
> > Collect more data, such as the size of the request and response. Try the
> > same request from a different platform (like your laptop or desktop).
> > Compare the network paths between the desktop and Android to the server.
>
> > I know you'd like to just get an answer "do this/try this". I hope that by
> > looking into the problem in more detail you''ll find a solution.
>
> > On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer 
> > > wrote:
> > > About 5 seconds, which isn't unbearable, but considering my app needs
> > > frequent requests some kind of optimization must be possible.
>
> > > Look at the android market...it seems to load everything pretty fast
> > > (much faster than my app at least!)
>
> > > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > > Considering that the execute method's latency includes network and 
> > > > server
> > > > times, on what basis do you think it's taking too long? What latency are
> > > you
> > > > observing, less than one second, more than one minute?
>
> > > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > > cbo...@gmail.com
>
> > > > > wrote:
> > > > > Yes, I've tried logging and the HTTP execute definitely takes the
> > > > > largest chunk of time, but how can I speed it up?  Is there another
> > > > > protocol/method?
>
> > > > > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > > > > wrote:
>
> > > > > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > > > > A guess would be that the HTTP network speed is 100's of times 
> > > > > > slower
> > > > > > than all the rest of the code. You might log the time before and
> > > after
> > > > > > the execute method if you haven't already done that.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to
> > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com > > > >  cr...@googlegroups.com> > > cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com > >  cr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread SizzlingSkizzorsProgrammer
Thanks a lot!  Just wondering:  how do you set the keep-alive
setting?  I just can't seem to get it!

Thanks for all your help!

On Jan 1, 5:08 pm, Frank Weiss  wrote:
> I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> java.net.URL.openConnection().getInputStream() and then parsing it with
> SAXParser. It looks like you're doing a POST to send form data(?) so you may
> have to stick with HTTPClient.
>
> If you're doing frequent requests, you can probably take advantage of
> HTTPClient's "keep-alive" connection management.
>
> If you're looking for optimizations, I strongly suggest you create a test
> app which performs the same request you're having performance problems with.
> Collect more data, such as the size of the request and response. Try the
> same request from a different platform (like your laptop or desktop).
> Compare the network paths between the desktop and Android to the server.
>
> I know you'd like to just get an answer "do this/try this". I hope that by
> looking into the problem in more detail you''ll find a solution.
>
> On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer 
>
>
> > wrote:
> > About 5 seconds, which isn't unbearable, but considering my app needs
> > frequent requests some kind of optimization must be possible.
>
> > Look at the android market...it seems to load everything pretty fast
> > (much faster than my app at least!)
>
> > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > Considering that the execute method's latency includes network and server
> > > times, on what basis do you think it's taking too long? What latency are
> > you
> > > observing, less than one second, more than one minute?
>
> > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com
>
> > > > wrote:
> > > > Yes, I've tried logging and the HTTP execute definitely takes the
> > > > largest chunk of time, but how can I speed it up?  Is there another
> > > > protocol/method?
>
> > > > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > > > wrote:
>
> > > > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > > > A guess would be that the HTTP network speed is 100's of times slower
> > > > > than all the rest of the code. You might log the time before and
> > after
> > > > > the execute method if you haven't already done that.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com > > >  cr...@googlegroups.com> > cr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread theSmith
You might also want to run a method trace around your network activity
to see where the most processing time is spent.  The results you get
wont be in actual time, but a relative time just because method
tracing is slow.

Just wrap you code with a start and stop calls, and make sure to have
the writing to external storage permission in your manifest.

// start tracing to "/sdcard/calc.trace"
Debug.startMethodTracing("calc");
// ...
// stop tracing
Debug.stopMethodTracing();


Traceview
http://developer.android.com/guide/developing/tools/traceview.html


-theSmith
On Jan 1, 7:08 pm, Frank Weiss  wrote:
> I've seen 5 sec occasionally getting an rss feed of about 28 KB using
> java.net.URL.openConnection().getInputStream() and then parsing it with
> SAXParser. It looks like you're doing a POST to send form data(?) so you may
> have to stick with HTTPClient.
>
> If you're doing frequent requests, you can probably take advantage of
> HTTPClient's "keep-alive" connection management.
>
> If you're looking for optimizations, I strongly suggest you create a test
> app which performs the same request you're having performance problems with.
> Collect more data, such as the size of the request and response. Try the
> same request from a different platform (like your laptop or desktop).
> Compare the network paths between the desktop and Android to the server.
>
> I know you'd like to just get an answer "do this/try this". I hope that by
> looking into the problem in more detail you''ll find a solution.
>
> On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer 
> > wrote:
> > About 5 seconds, which isn't unbearable, but considering my app needs
> > frequent requests some kind of optimization must be possible.
>
> > Look at the android market...it seems to load everything pretty fast
> > (much faster than my app at least!)
>
> > On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > > Considering that the execute method's latency includes network and server
> > > times, on what basis do you think it's taking too long? What latency are
> > you
> > > observing, less than one second, more than one minute?
>
> > > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> > cbo...@gmail.com
>
> > > > wrote:
> > > > Yes, I've tried logging and the HTTP execute definitely takes the
> > > > largest chunk of time, but how can I speed it up?  Is there another
> > > > protocol/method?
>
> > > > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > > > wrote:
>
> > > > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > > > A guess would be that the HTTP network speed is 100's of times slower
> > > > > than all the rest of the code. You might log the time before and
> > after
> > > > > the execute method if you haven't already done that.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Best HTTP Request Method

2010-01-01 Thread Frank Weiss
I've seen 5 sec occasionally getting an rss feed of about 28 KB using
java.net.URL.openConnection().getInputStream() and then parsing it with
SAXParser. It looks like you're doing a POST to send form data(?) so you may
have to stick with HTTPClient.

If you're doing frequent requests, you can probably take advantage of
HTTPClient's "keep-alive" connection management.

If you're looking for optimizations, I strongly suggest you create a test
app which performs the same request you're having performance problems with.
Collect more data, such as the size of the request and response. Try the
same request from a different platform (like your laptop or desktop).
Compare the network paths between the desktop and Android to the server.

I know you'd like to just get an answer "do this/try this". I hope that by
looking into the problem in more detail you''ll find a solution.

On Fri, Jan 1, 2010 at 3:36 PM, SizzlingSkizzorsProgrammer  wrote:

> About 5 seconds, which isn't unbearable, but considering my app needs
> frequent requests some kind of optimization must be possible.
>
> Look at the android market...it seems to load everything pretty fast
> (much faster than my app at least!)
>
> On Jan 1, 3:15 pm, Frank Weiss  wrote:
> > Considering that the execute method's latency includes network and server
> > times, on what basis do you think it's taking too long? What latency are
> you
> > observing, less than one second, more than one minute?
> >
> > On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer <
> cbo...@gmail.com
> >
> >
> >
> > > wrote:
> > > Yes, I've tried logging and the HTTP execute definitely takes the
> > > largest chunk of time, but how can I speed it up?  Is there another
> > > protocol/method?
> >
> > > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > > wrote:
> >
> > > > > It works fine, but it's quite slow...any way to make it faster?
> >
> > > > A guess would be that the HTTP network speed is 100's of times slower
> > > > than all the rest of the code. You might log the time before and
> after
> > > > the execute method if you haven't already done that.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com cr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread SizzlingSkizzorsProgrammer
About 5 seconds, which isn't unbearable, but considering my app needs
frequent requests some kind of optimization must be possible.

Look at the android market...it seems to load everything pretty fast
(much faster than my app at least!)

On Jan 1, 3:15 pm, Frank Weiss  wrote:
> Considering that the execute method's latency includes network and server
> times, on what basis do you think it's taking too long? What latency are you
> observing, less than one second, more than one minute?
>
> On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer 
>
>
> > wrote:
> > Yes, I've tried logging and the HTTP execute definitely takes the
> > largest chunk of time, but how can I speed it up?  Is there another
> > protocol/method?
>
> > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > wrote:
>
> > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > A guess would be that the HTTP network speed is 100's of times slower
> > > than all the rest of the code. You might log the time before and after
> > > the execute method if you haven't already done that.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread Kumar Bibek
I guess, the default Android's way is the best. Of course, you can add
more libraries, but then that would be redundant. I hope Google has
already taken care of the performance part.

Thanks and Regards,
Kumar Bibek

On Jan 2, 3:15 am, Frank Weiss  wrote:
> Considering that the execute method's latency includes network and server
> times, on what basis do you think it's taking too long? What latency are you
> observing, less than one second, more than one minute?
>
> On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer 
> > wrote:
> > Yes, I've tried logging and the HTTP execute definitely takes the
> > largest chunk of time, but how can I speed it up?  Is there another
> > protocol/method?
>
> > On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > > wrote:
>
> > > > It works fine, but it's quite slow...any way to make it faster?
>
> > > A guess would be that the HTTP network speed is 100's of times slower
> > > than all the rest of the code. You might log the time before and after
> > > the execute method if you haven't already done that.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Best HTTP Request Method

2010-01-01 Thread Frank Weiss
Considering that the execute method's latency includes network and server
times, on what basis do you think it's taking too long? What latency are you
observing, less than one second, more than one minute?

On Fri, Jan 1, 2010 at 1:19 PM, SizzlingSkizzorsProgrammer  wrote:

> Yes, I've tried logging and the HTTP execute definitely takes the
> largest chunk of time, but how can I speed it up?  Is there another
> protocol/method?
>
> On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> > On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> > wrote:
> >
> >
> >
> > > It works fine, but it's quite slow...any way to make it faster?
> >
> > A guess would be that the HTTP network speed is 100's of times slower
> > than all the rest of the code. You might log the time before and after
> > the execute method if you haven't already done that.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Best HTTP Request Method

2010-01-01 Thread SizzlingSkizzorsProgrammer
Yes, I've tried logging and the HTTP execute definitely takes the
largest chunk of time, but how can I speed it up?  Is there another
protocol/method?

On Dec 31 2009, 6:07 pm, jotobjects  wrote:
> On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
> wrote:
>
>
>
> > It works fine, but it's quite slow...any way to make it faster?
>
> A guess would be that the HTTP network speed is 100's of times slower
> than all the rest of the code. You might log the time before and after
> the execute method if you haven't already done that.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2009-12-31 Thread jotobjects


On Dec 31, 12:52 pm, SizzlingSkizzorsProgrammer 
wrote:

>
> It works fine, but it's quite slow...any way to make it faster?

A guess would be that the HTTP network speed is 100's of times slower
than all the rest of the code. You might log the time before and after
the execute method if you haven't already done that.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Best HTTP Request Method

2009-12-31 Thread Brion Emde
I use the form of execute that takes two parameters, the request
object and a request handler, like this:

HttpGet get = new HttpGet(URL);
try {
String response = mClient.execute(get, new BasicResponseHandler(), c);
JSONObject respJSO = new JSONObject(response);
Log.d(TAG, "Credentials: " + respJSO.toString(2));
} catch ... Any errors with the response go here see
BasicResponseHandler

I've found this to be much easier to deal with. I don't know about
speed though. It's probably doing the same stuff under the covers. At
least I don't have to deal with it.


On Dec 31, 1:52 pm, SizzlingSkizzorsProgrammer 
wrote:
> What is the best (fastest and most efficient) method of doing an HTTP
> Request?
>
> Currently I use:
>
> DefaultHttpClient httpclient= new DefaultHttpClient();
>
> HttpPost httpost = new HttpPost(uri);
>
> httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
>
> HttpResponse response = httpclient.execute(httpost);
> HttpEntity entity = response.getEntity();
> String sResponse = EntityUtils.toString(entity);
>
>                     if (close == true)
>                     {
>                         httpclient.getConnectionManager().shutdown();
>                     }
>
>                         if (entity != null)
>                         {
>                         entity.consumeContent();
>                         }
>
>                     return sResponse;
>
> It works fine, but it's quite slow...any way to make it faster?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en